Added check for live mouseenter/mouseleave events if bound to nested elements with the same selector. Fixes #5884.

This commit is contained in:
Gilmore Davidson 2011-04-17 10:34:38 -07:00 committed by John Resig
parent adef5c3550
commit a9b81d759a

View File

@ -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 ) {