From: Dave Methvin Date: Thu, 10 Mar 2011 03:38:26 +0000 (-0500) Subject: Fixes #8456. Make sure parent is not null before crawling into its lap, so mouseenter... X-Git-Tag: 1.5.2rc1~7^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2ac4067a639856a6035c3bd00aab132c9714b52d;p=jquery.git Fixes #8456. Make sure parent is not null before crawling into its lap, so mouseenter is triggered on a mouseover event. --- diff --git a/src/event.js b/src/event.js index f7e0a08c0..2620646da 100644 --- a/src/event.js +++ b/src/event.js @@ -661,7 +661,7 @@ var withinElement = function( event ) { // Chrome does something similar, the parentNode property // can be accessed but is null. - if ( parent !== document && !parent.parentNode ) { + if ( parent && parent !== document && !parent.parentNode ) { return; } // Traverse up the tree diff --git a/test/unit/event.js b/test/unit/event.js index b7b260462..d66aaac9b 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -683,6 +683,20 @@ test("hover()", function() { equals( times, 4, "hover handlers fired" ); }); +test("mouseover triggers mouseenter", function() { + expect(1); + + var count = 0, + elem = jQuery(""); + elem.mouseenter(function () { + count++; + }); + elem.trigger('mouseover'); + equals(count, 1, "make sure mouseover triggers a mouseenter" ); + + elem.remove(); +}); + test("trigger() shortcuts", function() { expect(6);