equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
reset();
var defaultText = 'Try them out:'
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
reset();
var defaultText = 'Try them out:'
ok( result.is('ol'), 'Check for element wrapping' );
equals( result.text(), defaultText, 'Check for element wrapping' );
ok( result.is('ol'), 'Check for element wrapping' );
equals( result.text(), defaultText, 'Check for element wrapping' );
jQuery('#check1').click(function() {
var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
jQuery('#check1').click(function() {
var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
}).click();
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
}).click();
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
equals( jQuery("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );
// Try wrapping a disconnected node
equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
equals( jQuery("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );
// Try wrapping a disconnected node
equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
-test("wrapAll(String|Element)", function() {
+test("wrap(Function)", function() {
+ testWrap(functionReturningObj);
+})
+
+var testWrapAll = function(val) {
expect(8);
var prev = jQuery("#firstp")[0].previousSibling;
var p = jQuery("#firstp,#first")[0].parentNode;
expect(8);
var prev = jQuery("#firstp")[0].previousSibling;
var p = jQuery("#firstp,#first")[0].parentNode;
equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );
equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );
equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
- equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );
+ equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );
+}
+
+test("wrapAll(String|Element)", function() {
+ testWrapAll(bareObj);
-/* test("wrapInner(Function)", function() {
- testWrapInner(functionReturningObj)
-}) */
+// TODO: wrapInner uses wrapAll -- get wrapAll working with Function
+// test("wrapInner(Function)", function() {
+// testWrapInner(functionReturningObj)
+// })
ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
reset();
ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
reset();
ok( jQuery("#first")[0], 'Replace element with element' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
reset();
ok( jQuery("#first")[0], 'Replace element with element' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
reset();
ok( jQuery("#first")[0], 'Replace element with array of elements' );
ok( jQuery("#mark")[0], 'Replace element with array of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
reset();
ok( jQuery("#first")[0], 'Replace element with array of elements' );
ok( jQuery("#mark")[0], 'Replace element with array of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
reset();
ok( jQuery("#first")[0], 'Replace element with set of elements' );
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
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 set of elements' );
+}
+
+test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
+ testReplaceWith(bareObj);
test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
expect(10);
jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");
test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
expect(10);
jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");