X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fevent.js;h=83a0797c88a3069184de018249515f8dfdf53e85;hb=b1018cad1256a7b9cc47e675b2a9e22c409b7aed;hp=e12f3b753c9e8be5cec65e5b2abfd861b1a0c51a;hpb=ec7baf230d3c246dadf00c94115e6668425b9354;p=jquery.git diff --git a/test/unit/event.js b/test/unit/event.js index e12f3b7..83a0797 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(36); + expect(38); var submit = 0, div = 0, livea = 0, liveb = 0; @@ -588,6 +588,20 @@ test(".live()/.die()", function() { // Cleanup jQuery("#nothiddendiv").die("foo", callback); + + // Make sure we don't loose the target by DOM modifications + // after the bubble already reached the liveHandler + var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('').get(0); + + jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); }); + jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} }); + + jQuery("#nothiddendiv span").click(); + equals( jQuery("#nothiddendiv span").length, 0, "Verify that first handler occurred and modified the DOM." ); + equals( livec, 1, "Verify that second handler occurred even with nuked target." ); + + // Cleanup + jQuery("#nothiddendivchild").die("click"); }); /*