Remove the relatedTarget adjustment for mouseenter/leave events, it's an ambiguous case anyway and it is expensive to do.

This commit is contained in:
Dave Methvin
2011-09-08 09:03:16 -04:00
committed by timmywil
parent 2886249e84
commit 38601e07da
2 changed files with 22 additions and 12 deletions

View File

@@ -699,8 +699,7 @@ jQuery.Event.prototype = {
isImmediatePropagationStopped: returnFalse
};
// Create mouseenter and mouseleave events; IE has its own native ones but
// we need to support event delegation as well so we don't use them.
// Create mouseenter/leave events using mouseover/out and event-time checks
jQuery.each({
mouseenter: "mouseover",
mouseleave: "mouseout"
@@ -716,12 +715,9 @@ jQuery.each({
selector = handleObj.selector,
oldType, ret;
// For a real mouseover/out, always call the handler; for
// mousenter/leave call the handler if related is outside the target.
// NB: No relatedTarget if the mouse left/entered the browser window
if ( selector && related ) {
// Delegated event; find the real relatedTarget
related = jQuery( related ).closest( selector )[0];
}
// For mouseover/out, contains isn't needed; handle() already determined it's the right target
if ( !related || handleObj.origType === event.type || (related !== target && !jQuery.contains( target, related )) ) {
oldType = event.type;
event.type = handleObj.origType;