X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=7db8d5bae0a2800fad2edbec77e91460ad485988;hb=f06e0e5575bc8f82d0fcbd5880bb9d8ccf361bfa;hp=e387d640eba82b04fb7cf6270c67a92e1b2148a3;hpb=4f9aa62a858f28b8ed310ac73f9d2cd788bf1eed;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index e387d64..7db8d5b 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -971,3 +971,73 @@ test("empty()", function() { equals( j.html(), "", "Check node,textnode,comment empty works" ); }); +test("jQuery.cleanData", function() { + expect(10); + + var type, pos, div, child; + + type = "remove"; + + // Should trigger 4 remove event + div = getDiv().remove(); + + // Should both do nothing + pos = "Outer"; + div.trigger("click"); + + pos = "Inner"; + div.children().trigger("click"); + + type = "empty"; + div = getDiv(); + child = div.children(); + + // Should trigger 2 remove event + div.empty(); + + // Should trigger 1 + pos = "Outer"; + div.trigger("click"); + + // Should do nothing + pos = "Inner"; + child.trigger("click"); + + type = "html"; + + div = getDiv(); + child = div.children(); + + // Should trigger 2 remove event + div.html("
"); + + // Should trigger 1 + pos = "Outer"; + div.trigger("click"); + + // Should do nothing + pos = "Inner"; + child.trigger("click"); + + function getDiv() { + var div = jQuery("
").click(function(){ + ok( true, type + " " + pos + " Click event fired." ); + }).focus(function(){ + ok( true, type + " " + pos + " Focus event fired." ); + }).find("div").click(function(){ + ok( false, type + " " + pos + " Click event fired." ); + }).focus(function(){ + ok( false, type + " " + pos + " Focus event fired." ); + }).end().appendTo("body"); + + div[0].detachEvent = div[0].removeEventListener = function(t){ + ok( true, type + " Outer " + t + " event unbound" ); + }; + + div[0].firstChild.detachEvent = div[0].firstChild.removeEventListener = function(t){ + ok( true, type + " Inner " + t + " event unbound" ); + }; + + return div; + } +}); \ No newline at end of file