Opened 12 years ago
Closed 12 years ago
#9357 closed bug (fixed)
'mouseenter' event handling swallows exceptions on withinElement
Reported by: | 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.
Change History (5)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → event |
---|---|
Priority: | undecided → high |
Status: | new → open |
Confirmed
comment:3 Changed 12 years ago by
Thanks, Bryan! I agree that moving the event call out of the try/catch seems like the right solution.
comment:5 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Note: See
TracTickets for help on using
tickets.
Found the commit: 6a82f2a https://github.com/jquery/jquery/commit/6a82f2ae63263ed9deaff9d9dcc775a2c0cde343