From: Gilmore Davidson Date: Sun, 17 Apr 2011 17:34:38 +0000 (-0700) Subject: Added check for live mouseenter/mouseleave events if bound to nested elements with... X-Git-Tag: 1.6rc1~11^2~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a9b81d759af3a4574a42ca1de93be1247f7953a2;p=jquery.git Added check for live mouseenter/mouseleave events if bound to nested elements with the same selector. Fixes #5884. --- diff --git a/src/event.js b/src/event.js index 92fe0cb3d..32d51d054 100644 --- a/src/event.js +++ b/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 ) {