X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=d4c43487192395dbfaadfeb183d4dada4fd8a17b;hb=d490bcfa7ca78a330e55b9267cc492a49c0f70bb;hp=97d4ca0261bc4426e0727ef98156367cbd5fd873;hpb=c5382ad7c118ca54dde630b6c7146f1c3b6afb80;p=jquery.git
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 97d4ca0..d4c4348 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -22,7 +22,9 @@ var testText = function(valueObj) {
j.text(valueObj("hi!"));
equals( jQuery(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
- equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
+
+ // Blackberry 4.6 doesn't maintain comments in the DOM
+ equals( jQuery("#nonnodes")[0].childNodes.length < 3 ? 8 : j[2].nodeType, 8, "Check node,textnode,comment with text()" );
}
test("text(String)", function() {
@@ -72,7 +74,9 @@ var testWrap = function(val) {
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
j.wrap(val( "" ));
- equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
+
+ // Blackberry 4.6 doesn't maintain comments in the DOM
+ equals( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[0].childNodes.length, "Check node,textnode,comment wraps ok" );
equals( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
// Try wrapping a disconnected node
@@ -265,7 +269,7 @@ var testAppend = function(valueObj) {
var body = jQuery("#iframe")[0].contentWindow.document.body;
pass = false;
- jQuery( document.body ).append(valueObj( "
test
" ));
+ jQuery( body ).append(valueObj( "test
" ));
pass = true;
} catch(e) {}
@@ -676,7 +680,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
});
var testReplaceWith = function(val) {
- expect(17);
+ expect(20);
jQuery('#yahoo').replaceWith(val( 'buga' ));
ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
@@ -744,6 +748,17 @@ var testReplaceWith = function(val) {
//"");
equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');
jQuery('.replacewith').remove();
+
+ QUnit.reset();
+
+ jQuery("#main").append("");
+ equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
+
+ jQuery("#replaceWith").replaceWith( val("") );
+ equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
+
+ jQuery("#replaceWith").replaceWith( val("") );
+ equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
}
test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
@@ -753,7 +768,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj);
- expect(18);
+ expect(21);
var y = jQuery("#yahoo")[0];
@@ -895,7 +910,7 @@ var testHtml = function(valueObj) {
equals( div.children().children().length, 1, "Make sure that a grandchild exists." );
var space = jQuery("").html(valueObj(" "))[0].innerHTML;
- ok( /^\s$|^ $/.test( space ), "Make sure entities are passed through correctly." );
+ ok( /^\xA0$|^ $/.test( space ), "Make sure entities are passed through correctly." );
equals( jQuery("").html(valueObj("&"))[0].innerHTML, "&", "Make sure entities are passed through correctly." );
jQuery("#main").html(valueObj(""));
@@ -951,6 +966,17 @@ test("html(String)", function() {
test("html(Function)", function() {
testHtml(functionReturningObj);
+
+ expect(33);
+
+ QUnit.reset();
+
+ jQuery("#main").html(function(){
+ return jQuery(this).text();
+ });
+
+ ok( !/ 0, "Make sure text exists." );
});
test("html(Function) with incoming value", function() {
@@ -980,6 +1006,11 @@ test("html(Function) with incoming value", function() {
equals( val, old[i], "Make sure the incoming value is correct." );
return "bold";
});
+
+ // Handle the case where no comment is in the document
+ if ( j.length === 2 ) {
+ equals( null, null, "Make sure the incoming value is correct." );
+ }
j.find('b').removeData();
equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "bold", "Check node,textnode,comment with html()" );
@@ -1034,7 +1065,8 @@ var testRemove = function(method) {
equals( jQuery("#ap").children().length, 0, "Check multi-filtered remove" );
// using contents will get comments regular, text, and comment nodes
- equals( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
+ // Handle the case where no comment is in the document
+ ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment remove works" );
jQuery("#nonnodes").contents()[method]();
equals( jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );