X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fevent.js;h=1da9b5906fab6429850851e7068941ef51e1e483;hb=9aa0c69c43bad9fce5ef7732692308afb2a38ec6;hp=4d2b0aafe246466bf9aae4921e9b9b63d9ac4fe3;hpb=0ae78024c23dd3ef4bcea883338d975dcf843597;p=jquery.git diff --git a/test/unit/event.js b/test/unit/event.js index 4d2b0aa..1da9b59 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(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"); }); /*