Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(jqLite): pass in a dummy event with triggerHandler #2408

Closed
wants to merge 1 commit into from

Conversation

juliemr
Copy link
Member

@juliemr juliemr commented Apr 15, 2013

Previously, anchor elements could not be used with triggerHandler because
triggerHandler passes null as the event, and any anchor element with an empty
href automatically calls event.preventDefault(). Instead, pass a dummy event
when using triggerHandler, similar to what full jQuery does. Modified from
PR #2379.

@petebacondarwin
Copy link
Contributor

This fails on both IE8 and IE9: http://ci.angularjs.org/job/angular.js-pete/77/

Previously, anchor elements could not be used with triggerHandler because
triggerHandler passes null as the event, and any anchor element with an empty
href automatically calls event.preventDefault(). Instead, pass a dummy event
when using triggerHandler, similar to what full jQuery does. Modified from
PR angular#2379.
@juliemr
Copy link
Member Author

juliemr commented Apr 17, 2013

Gah, IE. Thanks for pointing that out - should be fixed now.

@petebacondarwin
Copy link
Contributor

Hi, I think this is still failing: http://ci.angularjs.org/job/angular.js-pete/84/

@petebacondarwin
Copy link
Contributor

The problem here is that in IE the dummy event is missing some important functions. JQuery builds its own events from scratch, wrapping real ones if necessary. See https://github.com/jquery/jquery/blob/master/src/event.js#L610.

In our case we only want a dummy one. I have created this on my branch here: https://github.com/petebacondarwin/angular.js/compare/pr2408. This passes all CI tests.

My only concern is that it adds quite a lot of bytes for such a small issue. Also there is a certain amount of overlap with the code in createEventHandler and perhaps this should all be consolidated into a single object/function?

@juliemr
Copy link
Member Author

juliemr commented May 8, 2013

Sorry for the stall in responses! My immediate problem was fixed by the team deciding to just include jQuery in the whole app.

I agree with your concern. Maybe the initial fix from PR #2379 could work?

@petebacondarwin
Copy link
Contributor

@juliemr - Well to be honest if this is the only place where we are worrying about this then we could make our dummy object really small with simply preventDefault: noop

it('should pass a dummy event', function() {
var element = jqLite('<a>poke</a>'),
pokeSpy = jasmine.createSpy('poke'),
event;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is off

@IgorMinar
Copy link
Contributor

+1 for pete's suggestion

@IgorMinar
Copy link
Contributor

landed as 5e556ac25845128b4137daa337cdbc575924dac9

@IgorMinar IgorMinar closed this May 16, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants