diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2014-03-05 22:46:23 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2014-03-12 21:45:50 -0400 |
commit | 4c68d107b5054fcc37c689ada05c4099e3b6901d (patch) | |
tree | 6855e8100fc660b56309c359d811b6bb1bc34d9d /test | |
parent | 725cdebd3949ca98d4180897df5ddfd8ef58305b (diff) | |
download | jquery-4c68d107b5054fcc37c689ada05c4099e3b6901d.tar.gz jquery-4c68d107b5054fcc37c689ada05c4099e3b6901d.zip |
Event: Call underlying stopImmediatePropagation when present
Fixes #13997
(cherry picked from commit 6a89db86ed817f6a7498076e2a06b90f9fce0831)
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/event.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index 0cd181252..d6fece7c0 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -386,10 +386,13 @@ test("on immediate propagation", function() { $p.off( "click", "**" ); }); -test("on bubbling, isDefaultPrevented", function() { - expect(2); +test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { + expect( 3 ); var $anchor2 = jQuery( "#anchor2" ), $main = jQuery( "#qunit-fixture" ), + neverCallMe = function() { + ok( false, "immediate propagation should have been stopped" ); + }, fakeClick = function($jq) { // Use a native click so we don't get jQuery simulated bubbling if ( document.createEvent ) { @@ -427,6 +430,18 @@ test("on bubbling, isDefaultPrevented", function() { fakeClick( $anchor2 ); $anchor2.off( "click" ); $main.off( "click", "**" ); + + if ( !window.addEventListener ) { + ok( true, "Old IE, skipping native stopImmediatePropagation check" ); + } else { + $anchor2.on( "click", function( e ) { + e.stopImmediatePropagation(); + ok( true, "anchor was clicked and prop stopped" ); + }); + $anchor2[0].addEventListener( "click", neverCallMe, false ); + fakeClick( $anchor2 ); + $anchor2[0].removeEventListener( "click", neverCallMe ); + } }); test("on(), iframes", function() { |