Only detach the incoming elements to replaceWith if they're DOM nodes. Fixes #5986.
This commit is contained in:
parent
e76ba32ceb
commit
8660ea1ab6
2 changed files with 13 additions and 6 deletions
|
@ -650,7 +650,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
|
|||
});
|
||||
|
||||
var testReplaceWith = function(val) {
|
||||
expect(15);
|
||||
expect(17);
|
||||
jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
|
||||
ok( jQuery("#replace")[0], 'Replace element with string' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
|
||||
|
@ -660,6 +660,12 @@ var testReplaceWith = function(val) {
|
|||
ok( jQuery("#first")[0], 'Replace element with element' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
|
||||
|
||||
reset();
|
||||
jQuery("#main").append('<div id="bar"><div id="baz">Foo</div></div>');
|
||||
jQuery('#baz').replaceWith("Baz");
|
||||
equals( jQuery("#bar").text(),"Baz", 'Replace element with text' );
|
||||
ok( !jQuery("#baz")[0], 'Verify that original element is gone, after element' );
|
||||
|
||||
reset();
|
||||
jQuery('#yahoo').replaceWith(val( [document.getElementById('first'), document.getElementById('mark')] ));
|
||||
ok( jQuery("#first")[0], 'Replace element with array of elements' );
|
||||
|
@ -721,7 +727,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
|
|||
test("replaceWith(Function)", function() {
|
||||
testReplaceWith(functionReturningObj);
|
||||
|
||||
expect(16);
|
||||
expect(18);
|
||||
|
||||
var y = jQuery("#yahoo")[0];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue