Fixed bubbling of live events (if an inner element handles an event first - and stops progatation - then the parent event doesn't encounter the event). Thanks to Irae for the patch. Fixes bug #3980.

This commit is contained in:
John Resig 2009-02-09 23:29:57 +00:00
parent 0ae78024c2
commit 9aa0c69c43
5 changed files with 43 additions and 7 deletions

View file

@ -474,7 +474,7 @@ test("toggle(Function, Function, ...)", function() {
});
test(".live()/.die()", function() {
expect(42);
expect(46);
var submit = 0, div = 0, livea = 0, liveb = 0;
@ -611,6 +611,29 @@ test(".live()/.die()", function() {
// Cleanup
jQuery("#nothiddendivchild").die("click");
// Verify that .live() ocurs and cancel buble in the same order as
// we would expect .bind() and .click() without delegation
var lived = 0, livee = 0;
// bind one pair in one order
jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });
jQuery('span#liveSpan1').live('click', function(){ livee++; });
jQuery('span#liveSpan1 a').click();
equals( lived, 1, "Verify that only one first handler occurred." );
equals( livee, 0, "Verify that second handler don't." );
// and one pair in inverse
jQuery('#liveHandlerOrder span#liveSpan2').live('click', function(){ livee++; });
jQuery('#liveHandlerOrder span#liveSpan2 a').live('click', function(){ lived++; return false; });
jQuery('span#liveSpan2 a').click();
equals( lived, 2, "Verify that only one first handler occurred." );
equals( livee, 0, "Verify that second handler don't." );
// Cleanup
jQuery("span#liveSpan1 a, span#liveSpan1, span#liveSpan2 a, span#liveSpan2").die("click");
});
/*