Skip to content
Permalink
Browse files

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 a9b81d759af3a4574a42ca1de93be1247f7953a2
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/event.js
@@ -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 ) {

0 comments on commit a9b81d7

Please sign in to comment.
You can’t perform that action at this time.