Commit 03ab9b9f authored by Mark Raddatz's avatar Mark Raddatz Committed by Richard Gibson

Fix #13401: replaceWith(""). Close gh-1163.

(cherry picked from commit 6a0ee2d9)
parent 67a2e4ea
...@@ -265,7 +265,8 @@ jQuery.fn.extend({ ...@@ -265,7 +265,8 @@ jQuery.fn.extend({
value = jQuery( value ).not( this ).detach(); value = jQuery( value ).not( this ).detach();
} }
return this.domManip( [ value ], true, function( elem ) { return value !== "" ?
this.domManip( [ value ], true, function( elem ) {
var next = this.nextSibling, var next = this.nextSibling,
parent = this.parentNode; parent = this.parentNode;
...@@ -273,7 +274,8 @@ jQuery.fn.extend({ ...@@ -273,7 +274,8 @@ jQuery.fn.extend({
jQuery( this ).remove(); jQuery( this ).remove();
parent.insertBefore( elem, next ); parent.insertBefore( elem, next );
} }
}); }) :
this.remove();
}, },
detach: function( selector ) { detach: function( selector ) {
......
...@@ -1261,6 +1261,15 @@ test( "replaceWith(string) for more than one element", function() { ...@@ -1261,6 +1261,15 @@ 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"); equal(jQuery("#foo p").length, 0, "verify that all the three original element have been replaced");
}); });
test( "replaceWith(\"\") (#13401)", 4, function() {
expect( 1 );
var div = jQuery("<div><p></p></div>");
div.children().replaceWith("");
equal( div.html().toLowerCase(), "", "Replacing with empty string removes element" );
});
test( "replaceAll(String|Element|Array<Element>|jQuery)", function() { test( "replaceAll(String|Element|Array<Element>|jQuery)", function() {
expect( 10 ); expect( 10 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment