X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=16992aeb748336805f8f1681d3098c5167328dc1;hb=76236a15062aa82a4841748e9071eb3c9535ef62;hp=c250b53e7f733732dfbc977fecef52b3ad15e5d2;hpb=d431519d61f55af8bd1714d00126c948d888f3a9;p=jquery.git
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index c250b53..16992ae 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -139,11 +139,6 @@ test("wrapAll(String|Element)", function() {
testWrapAll(bareObj);
});
-// TODO: Figure out why each(wrapAll) is not equivalent to wrapAll
-// test("wrapAll(Function)", function() {
-// testWrapAll(functionReturningObj);
-// })
-
var testWrapInner = function(val) {
expect(8);
var num = jQuery("#first").children().length;
@@ -798,7 +793,7 @@ test("clone() on XML nodes", function() {
}
var testHtml = function(valueObj) {
- expect(22);
+ expect(24);
jQuery.scriptorder = 0;
@@ -810,6 +805,11 @@ var testHtml = function(valueObj) {
}
ok( pass, "Set HTML" );
+ div = jQuery("
").html( valueObj('') );
+
+ equals( div.children().length, 2, "Make sure two child nodes exist." );
+ equals( div.children().children().length, 1, "Make sure that a grandchild exists." );
+
reset();
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
@@ -976,3 +976,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;
+ }
+});