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"
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;
Mouse over here should NOT trigger the counter.
</div>
</div>
-
- <div id="livebox" class="hover-box">
+ <div id="liveenterbox" class="hover-box">
<div class="hover-status">
<button>Activate</button>
Live enter/leave: <span class="ins">0</span> / <span class="outs">0</span>
Mouse over here should NOT trigger the counter.
</div>
</div>
-
<div id="delegateenterbox" class="hover-box">
<div class="hover-status">
<button>Activate</button>
Mouse over here SHOULD trigger the counter.
</div>
</div>
+ <div id="liveoverbox" class="hover-box">
+ <div class="hover-status">
+ <button>Activate</button>
+ Live over/out: <span class="ins">0</span> / <span class="outs">0</span>
+ </div>
+ <div class="hover-inside">
+ Mouse over here SHOULD trigger the counter.
+ </div>
+ </div>
<div id="delegateoverbox" class="hover-box">
<div class="hover-status">
<button>Activate</button>
.delegate("#delegateenterbox", "mouseleave", countOuts );
$(this).remove();
});
- $("#livebox button").click(function(){
- $("#livebox")
+ $("#liveenterbox button").click(function(){
+ $("#liveenterbox")
.data({ ins: 0, outs: 0 })
.live("mouseenter", countIns )
.live("mouseleave", countOuts );
.bind("mouseout", countOuts );
$(this).remove();
});
+ $("#liveoverbox button").click(function(){
+ $("#liveoverbox")
+ .data({ ins: 0, outs: 0 })
+ .live("mouseover", countIns )
+ .live("mouseout", countOuts );
+ $(this).remove();
+ });
$("#delegateoverbox button").click(function(){
$(document)
.find("#delegateoverbox").data({ ins: 0, outs: 0 }).end()