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() {
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
j.wrap(val( "<i></i>" ));
- 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
QUnit.reset();
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
jQuery('#sap').append(valueObj(document.getElementById('first')));
- equals( expected, jQuery('#sap').text(), "Check for appending of element" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of element" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
jQuery('#sap').append(valueObj([document.getElementById('first'), document.getElementById('yahoo')]));
- equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
jQuery('#sap').append(valueObj(jQuery("#yahoo, #first")));
- equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
QUnit.reset();
jQuery("#sap").append(valueObj( 5 ));
var body = jQuery("#iframe")[0].contentWindow.document.body;
pass = false;
- jQuery( document.body ).append(valueObj( "<div>test</div>" ));
+ jQuery( body ).append(valueObj( "<div>test</div>" ));
pass = true;
} catch(e) {}
equals( val, old, "Make sure the incoming value is correct." );
return document.getElementById('first');
});
- equals( expected, jQuery('#sap').text(), "Check for appending of element" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of element" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
equals( val, old, "Make sure the incoming value is correct." );
return [document.getElementById('first'), document.getElementById('yahoo')];
});
- equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
equals( val, old, "Make sure the incoming value is correct." );
return jQuery("#yahoo, #first");
});
- equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
QUnit.reset();
old = jQuery("#sap").html();
QUnit.reset();
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
jQuery(document.getElementById('first')).appendTo('#sap');
- equals( expected, jQuery('#sap').text(), "Check for appending of element" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of element" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
- equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
QUnit.reset();
ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
jQuery("#yahoo, #first").appendTo('#sap');
- equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
+ equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
QUnit.reset();
jQuery('#select1').appendTo('#foo');
QUnit.reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').prepend(val( document.getElementById('first') ));
- equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
QUnit.reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').prepend(val( [document.getElementById('first'), document.getElementById('yahoo')] ));
- equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
QUnit.reset();
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').prepend(val( jQuery("#yahoo, #first") ));
- equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
};
test("prepend(String|Element|Array<Element>|jQuery)", function() {
return document.getElementById('first');
});
- equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
QUnit.reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
return [document.getElementById('first'), document.getElementById('yahoo')];
});
- equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
QUnit.reset();
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
return jQuery("#yahoo, #first");
});
- equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
});
test("prependTo(String|Element|Array<Element>|jQuery)", function() {
QUnit.reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery(document.getElementById('first')).prependTo('#sap');
- equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
QUnit.reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).prependTo('#sap');
- equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
QUnit.reset();
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery("#yahoo, #first").prependTo('#sap');
- equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
+ equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
QUnit.reset();
jQuery('<select id="prependSelect1"></select>').prependTo('form:last');
expect(6);
var expected = 'This is a normal link: bugaYahoo';
jQuery('#yahoo').before(val( '<b>buga</b>' ));
- equals( expected, jQuery('#en').text(), 'Insert String before' );
+ equals( jQuery('#en').text(), expected, 'Insert String before' );
QUnit.reset();
expected = "This is a normal link: Try them out:Yahoo";
jQuery('#yahoo').before(val( document.getElementById('first') ));
- equals( expected, jQuery('#en').text(), "Insert element before" );
+ equals( jQuery('#en').text(), expected, "Insert element before" );
QUnit.reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
jQuery('#yahoo').before(val( [document.getElementById('first'), document.getElementById('mark')] ));
- equals( expected, jQuery('#en').text(), "Insert array of elements before" );
+ equals( jQuery('#en').text(), expected, "Insert array of elements before" );
QUnit.reset();
expected = "This is a normal link: diveintomarkTry them out:Yahoo";
- jQuery('#yahoo').before(val( jQuery("#first, #mark") ));
- equals( expected, jQuery('#en').text(), "Insert jQuery before" );
+ jQuery('#yahoo').before(val( jQuery("#mark, #first") ));
+ equals( jQuery('#en').text(), expected, "Insert jQuery before" );
var set = jQuery("<div/>").before("<span>test</span>");
equals( set[0].nodeName.toLowerCase(), "span", "Insert the element before the disconnected node." );
expect(4);
var expected = 'This is a normal link: bugaYahoo';
jQuery('<b>buga</b>').insertBefore('#yahoo');
- equals( expected, jQuery('#en').text(), 'Insert String before' );
+ equals( jQuery('#en').text(), expected, 'Insert String before' );
QUnit.reset();
expected = "This is a normal link: Try them out:Yahoo";
jQuery(document.getElementById('first')).insertBefore('#yahoo');
- equals( expected, jQuery('#en').text(), "Insert element before" );
+ equals( jQuery('#en').text(), expected, "Insert element before" );
QUnit.reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
jQuery([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
- equals( expected, jQuery('#en').text(), "Insert array of elements before" );
+ equals( jQuery('#en').text(), expected, "Insert array of elements before" );
QUnit.reset();
expected = "This is a normal link: diveintomarkTry them out:Yahoo";
- jQuery("#first, #mark").insertBefore('#yahoo');
- equals( expected, jQuery('#en').text(), "Insert jQuery before" );
+ jQuery("#mark, #first").insertBefore('#yahoo');
+ equals( jQuery('#en').text(), expected, "Insert jQuery before" );
});
var testAfter = function(val) {
expect(6);
var expected = 'This is a normal link: Yahoobuga';
jQuery('#yahoo').after(val( '<b>buga</b>' ));
- equals( expected, jQuery('#en').text(), 'Insert String after' );
+ equals( jQuery('#en').text(), expected, 'Insert String after' );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:";
jQuery('#yahoo').after(val( document.getElementById('first') ));
- equals( expected, jQuery('#en').text(), "Insert element after" );
+ equals( jQuery('#en').text(), expected, "Insert element after" );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:diveintomark";
jQuery('#yahoo').after(val( [document.getElementById('first'), document.getElementById('mark')] ));
- equals( expected, jQuery('#en').text(), "Insert array of elements after" );
+ equals( jQuery('#en').text(), expected, "Insert array of elements after" );
QUnit.reset();
expected = "This is a normal link: YahoodiveintomarkTry them out:";
- jQuery('#yahoo').after(val( jQuery("#first, #mark") ));
- equals( expected, jQuery('#en').text(), "Insert jQuery after" );
+ jQuery('#yahoo').after(val( jQuery("#mark, #first") ));
+ equals( jQuery('#en').text(), expected, "Insert jQuery after" );
var set = jQuery("<div/>").after("<span>test</span>");
equals( set[1].nodeName.toLowerCase(), "span", "Insert the element after the disconnected node." );
expect(4);
var expected = 'This is a normal link: Yahoobuga';
jQuery('<b>buga</b>').insertAfter('#yahoo');
- equals( expected, jQuery('#en').text(), 'Insert String after' );
+ equals( jQuery('#en').text(), expected, 'Insert String after' );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:";
jQuery(document.getElementById('first')).insertAfter('#yahoo');
- equals( expected, jQuery('#en').text(), "Insert element after" );
+ equals( jQuery('#en').text(), expected, "Insert element after" );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:diveintomark";
jQuery([document.getElementById('first'), document.getElementById('mark')]).insertAfter('#yahoo');
- equals( expected, jQuery('#en').text(), "Insert array of elements after" );
+ equals( jQuery('#en').text(), expected, "Insert array of elements after" );
QUnit.reset();
expected = "This is a normal link: YahoodiveintomarkTry them out:";
- jQuery("#first, #mark").insertAfter('#yahoo');
- equals( expected, jQuery('#en').text(), "Insert jQuery after" );
+ jQuery("#mark, #first").insertAfter('#yahoo');
+ equals( jQuery('#en').text(), expected, "Insert jQuery after" );
});
var testReplaceWith = function(val) {
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
QUnit.reset();
- jQuery('#yahoo').replaceWith(val( jQuery("#first, #mark") ));
+ jQuery('#yahoo').replaceWith(val( jQuery("#mark, #first") ));
ok( jQuery("#first")[0], 'Replace element with set of elements' );
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
QUnit.reset();
- jQuery("#first, #mark").replaceAll("#yahoo");
+ jQuery("#mark, #first").replaceAll("#yahoo");
ok( jQuery("#first")[0], 'Replace element with set of elements' );
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
equals( val, old[i], "Make sure the incoming value is correct." );
return "<b>bold</b>";
});
+
+ // 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(), "<b>bold</b>", "Check node,textnode,comment with html()" );
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" );