Skip to content
Permalink
Browse files

Event: Call underlying stopImmediatePropagation when present

Fixes #13997
  • Loading branch information...
dmethvin committed Mar 6, 2014
1 parent 26ce217 commit 6a89db86ed817f6a7498076e2a06b90f9fce0831
Showing with 20 additions and 2 deletions.
  1. +7 −0 src/event.js
  2. +13 −2 test/unit/event.js
@@ -683,7 +683,14 @@ jQuery.Event.prototype = {
}
},
stopImmediatePropagation: function() {
var e = this.originalEvent;

this.isImmediatePropagationStopped = returnTrue;

if ( e && e.stopImmediatePropagation ) {
e.stopImmediatePropagation();
}

this.stopPropagation();
}
};
@@ -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
var e = document.createEvent( "MouseEvents" );
@@ -414,6 +417,14 @@ test("on bubbling, isDefaultPrevented", function() {
fakeClick( $anchor2 );
$anchor2.off( "click" );
$main.off( "click", "**" );

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

0 comments on commit 6a89db8

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.