Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added check for live mouseenter/mouseleave events if bound to nested …
…elements with the same selector. Fixes #5884.
  • Loading branch information
gilmoreorless authored and jeresig committed Apr 17, 2011
1 parent adef5c3 commit a9b81d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/event.js
Expand Up @@ -1137,6 +1137,11 @@ function liveHandler( event ) {
if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
event.type = handleObj.preType;
related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];

// Make sure not to accidentally match a child element with the same selector
if ( related && jQuery.contains( elem, related ) ) {
related = elem;
}
}

if ( !related || related !== elem ) {
Expand Down

0 comments on commit a9b81d7

Please sign in to comment.