From a78557472ce1c2cdf7db01a13fcc8591f3fdcfb0 Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 20 Jan 2009 17:25:37 +0000 Subject: [PATCH] Focused support of .live(). stopPropagation and stopImmediatePropagation are not supported - and do not do what the use would expect. --- src/event.js | 5 ++--- test/unit/event.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/event.js b/src/event.js index 5ae4bad..fdf61ba 100644 --- a/src/event.js +++ b/src/event.js @@ -572,9 +572,8 @@ function liveHandler( event ){ }); jQuery.each(elems, function(){ - if ( !event.isImmediatePropagationStopped() && - this.fn.call(this.elem, event, this.fn.data) === false ) - stop = false; + if ( this.fn.call(this.elem, event, this.fn.data) === false ) + stop = false; }); return stop; diff --git a/test/unit/event.js b/test/unit/event.js index 83a0797..4d2b0aa 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -474,7 +474,7 @@ test("toggle(Function, Function, ...)", function() { }); test(".live()/.die()", function() { - expect(38); + expect(42); var submit = 0, div = 0, livea = 0, liveb = 0; @@ -533,6 +533,15 @@ test(".live()/.die()", function() { equals( livea, 5, "die Click on inner div" ); equals( liveb, 2, "die Click on inner div" ); + // Make sure that stopPropgation doesn't stop live events + jQuery("div#nothiddendivchild").live("click", function(e){ liveb++; e.stopPropagation(); }); + jQuery("div#nothiddendivchild").trigger("click"); + equals( submit, 1, "stopPropagation Click on inner div" ); + equals( div, 6, "stopPropagation Click on inner div" ); + equals( livea, 6, "stopPropagation Click on inner div" ); + equals( liveb, 3, "stopPropagation Click on inner div" ); + + jQuery("div#nothiddendivchild").die("click"); jQuery("div#nothiddendiv").die("click"); jQuery("div").die("click"); jQuery("div").die("submit"); -- 1.7.10.4