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

fix(jqLite): mouseenter/-leave should not trigger on child elements #2134

Closed

Conversation

florianorben
Copy link

Mouseenter and mouseleave events were triggered on children of the
element they were bound to.
Change this to the expected behaviour, to only be triggered when
leaving/entering the actual element, not its children.

Closes #2131

Mouseenter and mouseleave events were triggered on children of the
element they were bound to.
Change this to the expected behaviour, to only be triggered when
leaving/entering the actual element, not its children.

Closes angular#2131
@IgorMinar
Copy link
Contributor

this is how jquery implements these event handlers. unfortunately we can't make jqlite incompatible with jquery.

if I missed something please provide more info and reopen this PR

@IgorMinar IgorMinar closed this Mar 12, 2013
@florianorben
Copy link
Author

Hey,

I think you're mixing up mouseenter/-leave with mouseover/-out.
Mouseenter/-leave will not fire until the cursor entered/left the bounding rectangles of the element it was applied to (i.e. it won't fire on child elements), whereas mouseover/out will fire if you're actually leaving the element (e.g. if you hover its child elems).
Jquery has this right, but angular bugs here.

See here for an example (check console for logs):
Angular: http://plnkr.co/edit/4bxQdYwgrdW1tYXsMeUE?p=preview
Jquery: http://plnkr.co/edit/8bseACWjkEO4lj2Q0pmv

@florianorben
Copy link
Author

Stupid question perhaps, but I dont see the option to re-open the PR, do I have to do another push to this branch?

@florianorben
Copy link
Author

Hey @IgorMinar, did you have time to look at the provided examples, as they show the differences between angular's and jquery's behaviours...?
As I said, I can't reopen the PR, probably because you closed it ;).

(See here for an example (check console for logs):
Angular: http://plnkr.co/edit/4bxQdYwgrdW1tYXsMeUE?p=preview
Jquery: http://plnkr.co/edit/8bseACWjkEO4lj2Q0pmv)

@ghost
Copy link

ghost commented Apr 9, 2013

+1
It took me a while to understand there was nothing wrong with my code. I'm surprised there aren't more people interested in this issue.

@neilsarkar
Copy link

+1

Anyone have a workaround besides just using jquery?

@sshepard
Copy link

sshepard commented Aug 1, 2014

I found a non-jQuery solution here:
http://cvmlrobotics.blogspot.com/2013/05/angularjs-incorrect-ng-mouseenter-ng.html

This is still a problem in AngularJS 1.2.16, especially for IE8.

@johnwojtk
Copy link

@IgorMinar, @florianorben is correct. jQuery does not implement mouseenter and mouseleave in this way. Ben Nadel's video, linked to below, explains this at 1:20.

http://www.bennadel.com/blog/1805-jquery-events-mouseover-mouseout-vs-mouseenter-mouseleave.htm

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.

Wrong behavior of 'mouseenter' and 'mouseleave' inside nested elements.
5 participants