#12140 closed bug (duplicate)
Incorrect event type reported on hover within a setTimeout
Reported by: | Motty | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | git |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When I add a setTimeout within a hover function, the e.type returns "mouseover" and "mouseout" instead of "mouseenter" and "mouseleave".
jsFiddle: http://jsfiddle.net/Mottie/P6gCg/1/
$('#test').hover(function(e){ console.log(e.type); setTimeout(function(){ console.log('after timeout: ' + e.type); }, 0); });
This problem occurs in jQuery v1.6.4+. Versions prior to this report the correct event type.
Change History (4)
comment:1 Changed 11 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
Hmm, ok I get the same incorrect event types when I bind to "mouseenter" and "mouseleave" (http://jsfiddle.net/Mottie/P6gCg/3/):
$('#test').bind('mouseenter mouseleave', function(e){ console.log(e.type); setTimeout(function(){ console.log('after timeout: ' + e.type); }, 0); });
Again, this happens in jQuery 1.6.4+
comment:4 Changed 11 years ago by
The event
object is valid only for the duration of the event. After it returns you can't expect it to remain unchanged. In fact, the entire native event object (event.originalEvent
) cannot be read in IE6/7/8 after the event has passed--it's gone and will throw an error if you try to access it. If you need an unchanging copy of some event
data, make one.
Duplicate of #11690.