From 974b5aeab7a3788ff5fb9db87b9567784e0249fc Mon Sep 17 00:00:00 2001 From: dmethvin Date: Sat, 23 Oct 2010 14:36:24 -0400 Subject: Honor stopImmediatePropagation for live/delegate event handlers. Fixes #7217. --- test/unit/event.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/unit') diff --git a/test/unit/event.js b/test/unit/event.js index 5efa0ec51..54431dd33 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -265,6 +265,36 @@ test("live/die(Object), delegate/undelegate(String, Object)", function() { equals( mouseoverCounter, 4, "die" ); }); +test("live/delegate immediate propagation", function() { + expect(2); + + var $p = jQuery("#firstp"), $a = $p.find("a:first"), lastClick; + + lastClick = ""; + $a.live( "click", function(e) { + lastClick = "click1"; + e.stopImmediatePropagation(); + }); + $a.live( "click", function(e) { + lastClick = "click2"; + }); + $a.trigger( "click" ); + equals( lastClick, "click1", "live stopImmediatePropagation" ); + $a.die( "click" ); + + lastClick = ""; + $p.delegate( "a", "click", function(e) { + lastClick = "click1"; + e.stopImmediatePropagation(); + }); + $p.delegate( "a", "click", function(e) { + lastClick = "click2"; + }); + $a.trigger( "click" ); + equals( lastClick, "click1", "delegate stopImmediatePropagation" ); + $p.undelegate( "click" ); +}); + test("bind(), iframes", function() { // events don't work with iframes, see #939 - this test fails in IE because of contentDocument var doc = jQuery("#loadediframe").contents(); -- cgit v1.2.3