Bug Tracker

Opened 12 years ago

Closed 12 years ago

#9357 closed bug (fixed)

'mouseenter' event handling swallows exceptions on withinElement

Reported by: [email protected] Owned by:
Priority: high Milestone: 1.next
Component: event Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:


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() {

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 ) {

		// 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.


Change History (5)

comment:2 Changed 12 years ago by Rick Waldron

Component: unfiledevent
Priority: undecidedhigh
Status: newopen

comment:3 Changed 12 years ago by dmethvin

Thanks, Bryan! I agree that moving the event call out of the try/catch seems like the right solution.

comment:4 Changed 12 years ago by Rick Waldron

Tested this pull request, full pass.


comment:5 Changed 12 years ago by rwldrn

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.