+test("jQuery.cleanData", function() {
+ expect(14);
+
+ 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");
+
+ // Should trigger 2
+ div.remove();
+
+ type = "html";
+
+ div = getDiv();
+ child = div.children();
+
+ // Should trigger 2 remove event
+ div.html("<div></div>");
+
+ // Should trigger 1
+ pos = "Outer";
+ div.trigger("click");
+
+ // Should do nothing
+ pos = "Inner";
+ child.trigger("click");
+
+ // Should trigger 2
+ div.remove();
+
+ function getDiv() {
+ var div = jQuery("<div class='outer'><div class='inner'></div></div>").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;
+ }
+});
+
+test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
+ expect(1);
+
+ // DOM manipulation fails if added text matches an Object method
+ var $f = jQuery( "<div />" ).appendTo( "#main" ),
+ bad = [ "start-", "toString", "hasOwnProperty", "append", "here&there!", "-end" ];
+
+ for ( var i=0; i < bad.length; i++ ) {
+ try {
+ $f.append( bad[i] );
+ }
+ catch(e) {}
+ }
+ equals($f.text(), bad.join(''), "Cached strings that match Object properties");
+ $f.remove();
+});