diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-12-08 14:49:42 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-12-09 14:10:38 -0500 |
commit | f8f52cfcf4ff5d0e3e50a73b03aff0fd9c72105b (patch) | |
tree | 2281a5b7cf57e86c17f2736ff1b156547369a2a8 /test/unit/manipulation.js | |
parent | d343e6b9ed501052f1676694d5e53649c92e65a0 (diff) | |
download | jquery-f8f52cfcf4ff5d0e3e50a73b03aff0fd9c72105b.tar.gz jquery-f8f52cfcf4ff5d0e3e50a73b03aff0fd9c72105b.zip |
Fix #13019. Disconnected nodes with .replaceWith are a noop. Close gh-1062.
Diffstat (limited to 'test/unit/manipulation.js')
-rw-r--r-- | test/unit/manipulation.js | 45 |
1 files changed, 3 insertions, 42 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 8382b6282..c32001bab 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1230,11 +1230,9 @@ var testReplaceWith = function( val ) { QUnit.reset(); set = jQuery("<div/>").replaceWith(val("<span>test</span>")); - equal( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." ); - equal( set.length, 1, "Replace the disconnected node." ); - - // #11338 - ok( jQuery("<div>1</div>").replaceWith( val("<span/>") ).is("span"), "#11338, Make sure disconnected node with content is replaced" ); + equal( set[0].nodeName.toLowerCase(), "div", "No effect on a disconnected node." ); + equal( set.length, 1, "No effect on a disconnected node." ); + equal( set[0].childNodes.length, 0, "No effect on a disconnected node." ); non_existant = jQuery("#does-not-exist").replaceWith( val("<b>should not throw an error</b>") ); equal( non_existant.length, 0, "Length of non existant element." ); @@ -1288,43 +1286,6 @@ test( "replaceWith(string) for more than one element", function() { equal(jQuery("#foo p").length, 0, "verify that all the three original element have been replaced"); }); -test( "replaceWith(string) for collection with disconnected element", function() { - - expect( 18 ); - - var testSet, newSet, - elem = jQuery("<div />"); - - - QUnit.reset(); - testSet = jQuery("#foo p").add( elem ); - equal( testSet.length, 4, "ensuring that test data has not changed" ); - - newSet = testSet.replaceWith("<span>bar</span>"); - equal( testSet.length, 4, "ensure that we still have the same number of elements" ); - equal( jQuery("#foo span").length, 3, "verify that all the three original elements have been replaced" ); - equal( jQuery("#foo p").length, 0, "verify that all the three original elements have been replaced" ); - equal( testSet.filter("p").length, 3, "ensure we still have the original set of attached elements" ); - equal( testSet.filter("div").length, 0, "ensure the detached element is not in the original set" ); - equal( newSet.filter("p").length, 3, "ensure we still have the original set of attached elements in new set" ); - equal( newSet.filter("div").length, 0, "ensure the detached element has been replaced in the new set" ); - equal( newSet.filter("span").length, 1, "ensure the new element is in the new set" ); - - QUnit.reset(); - testSet = elem.add( jQuery("#foo p") ); - equal( testSet.length, 4, "ensuring that test data has not changed" ); - - testSet.replaceWith("<span>bar</span>"); - equal( testSet.length, 4, "ensure that we still have the same number of elements" ); - equal( jQuery("#foo span").length, 3, "verify that all the three original elements have been replaced" ); - equal( jQuery("#foo p").length, 0, "verify that all the three original elements have been replaced" ); - equal( testSet.filter("p").length, 3, "ensure we still have the original set of attached elements" ); - equal( testSet.filter("div").length, 0, "ensure the detached element is not in the original set" ); - equal( newSet.filter("p").length, 3, "ensure we still have the original set of attached elements in new set" ); - equal( newSet.filter("div").length, 0, "ensure the detached element has been replaced in the new set" ); - equal( newSet.filter("span").length, 1, "ensure the new element is in the new set" ); -}); - test( "replaceAll(String|Element|Array<Element>|jQuery)", function() { expect( 10 ); |