Side navigation
#9357 closed bug (fixed)
Opened May 20, 2011 03:29AM UTC
Closed June 14, 2011 07:42PM UTC
'mouseenter' event handling swallows exceptions on withinElement
| Reported by: | bryan@millz.net | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.next |
| Component: | event | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
This was previously reported 'fixed' in jquery 1.4: http://bugs.jquery.com/ticket/5514 but seems to have regressed.
Given the following code:
$('a#id').bind('mouseenter', function() {
aler('bar');
});
JSFiddle: http://jsfiddle.net/3X2tg/6/
When triggering the 'mouseenter' event, no error message is printed to console. It appears the exception is being simply being swallowed here:
// Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
// set the correct event type
event.type = event.data;
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
// Chrome does something similar, the parentNode property
// can be accessed but is null.
if ( parent && parent !== document && !parent.parentNode ) {
return;
}
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
}
if ( parent !== this ) {
// handle event if we actually just moused on to a non sub-element
jQuery.event.handle.apply( this, arguments );
}
// assuming we've left the element since we most likely mousedover a xul element
} catch(e) { }
}
As detailed in the previous ticket, it appears the apply() call should probably be moved outside of the try/catch block.
Thanks.
Attachments (0)
Change History (5)
Changed May 20, 2011 03:36AM UTC by comment:1
Changed May 20, 2011 02:13PM UTC by comment:2
| component: | unfiled → event |
|---|---|
| priority: | undecided → high |
| status: | new → open |
Changed May 20, 2011 03:42PM UTC by comment:3
Thanks, Bryan! I agree that moving the event call out of the try/catch seems like the right solution.
Changed May 27, 2011 05:53PM UTC by comment:4
Tested this pull request, full pass.
Changed June 14, 2011 07:42PM UTC by comment:5
| resolution: | → fixed |
|---|---|
| status: | open → closed |
Landing pull request 397. withinElement rewrite in event. Fixes #6234, #9357, #9447.
More Details:
- https://github.com/jquery/jquery/pull/397
- http://bugs.jquery.com/ticket/6234
- http://bugs.jquery.com/ticket/9357
- http://bugs.jquery.com/ticket/9447
Changeset: 6926247bf441deaa0441872849bb3786c257a4cf
Found the commit: 6a82f2a
https://github.com/jquery/jquery/commit/6a82f2ae63263ed9deaff9d9dcc775a2c0cde343