Side navigation
#12140 closed bug (duplicate)
Opened July 25, 2012 05:52AM UTC
Closed July 25, 2012 05:58AM UTC
Last modified July 25, 2012 05:26PM UTC
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.
Attachments (0)
Change History (4)
Changed July 25, 2012 05:58AM UTC by comment:1
resolution: | → duplicate |
---|---|
status: | new → closed |
Changed July 25, 2012 05:06PM UTC by comment:3
_comment0: | 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); \ }); \ }}} → 1343236060546057 |
---|
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+
Changed July 25, 2012 05:26PM UTC by comment:4
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.