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

fix(a): allow jqLite triggerHandler('click') on anchors #2379

Closed
wants to merge 1 commit into from

Conversation

juliemr
Copy link
Member

@juliemr juliemr commented Apr 11, 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(). Add a check that event
exists before calling preventDefault.

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(). Add a check that event
exists before calling preventDefault.
@ghost ghost assigned vojtajina Apr 11, 2013
@vojtajina
Copy link
Contributor

This is bug of jqLite imho. It should pass a bogus event. Can you confirm real jQuery behavior ? But I'm pretty sure that jQuery would pass the event (https://github.com/jquery/jquery/blob/master/src/event.js#L237-L239).

I think we should fix jqLite, rather than adding this "if".

@vojtajina vojtajina closed this Apr 11, 2013
@juliemr
Copy link
Member Author

juliemr commented Apr 12, 2013

Real jQuery does indeed pass a fake event through triggerHandler. I'll make a PR for jqLite.

@juliemr juliemr deleted the allow-a-click-triggerhandler branch April 15, 2013 22:02
juliemr added a commit to juliemr/angular.js that referenced this pull request Apr 17, 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 angular#2379.
IgorMinar pushed a commit that referenced this pull request May 16, 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.
IgorMinar pushed a commit that referenced this pull request May 16, 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.
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.

2 participants