mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Fix #13401: replaceWith(""). Close gh-1163.
This commit is contained in:
parent
dc9b009c13
commit
6a0ee2d9ed
@ -241,15 +241,17 @@ jQuery.fn.extend({
|
||||
value = jQuery( value ).not( this ).detach();
|
||||
}
|
||||
|
||||
return this.domManip( [ value ], true, function( elem ) {
|
||||
var next = this.nextSibling,
|
||||
parent = this.parentNode;
|
||||
return value !== "" ?
|
||||
this.domManip( [ value ], true, function( elem ) {
|
||||
var next = this.nextSibling,
|
||||
parent = this.parentNode;
|
||||
|
||||
if ( parent ) {
|
||||
jQuery( this ).remove();
|
||||
parent.insertBefore( elem, next );
|
||||
}
|
||||
});
|
||||
if ( parent ) {
|
||||
jQuery( this ).remove();
|
||||
parent.insertBefore( elem, next );
|
||||
}
|
||||
}) :
|
||||
this.remove();
|
||||
},
|
||||
|
||||
detach: function( selector ) {
|
||||
|
@ -1219,6 +1219,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");
|
||||
});
|
||||
|
||||
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() {
|
||||
|
||||
expect( 10 );
|
||||
|
Loading…
Reference in New Issue
Block a user