Skip to main content

Bug Tracker

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: Owned by:
Priority: high Milestone:
Component: event Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

This was previously reported 'fixed' in jquery 1.4: but seems to have regressed.

Given the following code:

$('a#id').bind('mouseenter', function() {


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 =;

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


Attachments (0)
Change History (5)

Changed May 20, 2011 03:36AM UTC by anonymous comment:1

Changed May 20, 2011 02:13PM UTC by rwaldron comment:2

component: unfiledevent
priority: undecidedhigh
status: newopen

Changed May 20, 2011 03:42PM UTC by dmethvin 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 rwaldron comment:4

Tested this pull request, full pass.

Changed June 14, 2011 07:42PM UTC by rwldrn comment:5

resolution: → fixed
status: openclosed

Landing pull request 397. withinElement rewrite in event. Fixes #6234, #9357, #9447.

More Details:

Changeset: 6926247bf441deaa0441872849bb3786c257a4cf