aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-12-08 14:49:42 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-12-09 14:10:38 -0500
commitf8f52cfcf4ff5d0e3e50a73b03aff0fd9c72105b (patch)
tree2281a5b7cf57e86c17f2736ff1b156547369a2a8 /src
parentd343e6b9ed501052f1676694d5e53649c92e65a0 (diff)
downloadjquery-f8f52cfcf4ff5d0e3e50a73b03aff0fd9c72105b.tar.gz
jquery-f8f52cfcf4ff5d0e3e50a73b03aff0fd9c72105b.zip
Fix #13019. Disconnected nodes with .replaceWith are a noop. Close gh-1062.
Diffstat (limited to 'src')
-rw-r--r--src/manipulation.js14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index e3026426d..c19217c43 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -249,8 +249,7 @@ jQuery.fn.extend({
},
replaceWith: function( value ) {
- var self = this,
- isFunc = jQuery.isFunction( value );
+ var isFunc = jQuery.isFunction( value );
// Make sure that the elements are removed from the DOM before they are inserted
// this can help fix replacing a parent with child elements
@@ -258,17 +257,10 @@ jQuery.fn.extend({
value = jQuery( value ).detach();
}
- return this.domManip( [ value ], true, function( elem, i ) {
+ return this.domManip( [ value ], true, function( elem ) {
var next, parent;
- if ( isDisconnected( this ) ) {
- // for disconnected elements, we simply replace
- // with the new content in the set
- self[ i ] = elem;
- return;
- }
-
- if ( this.nodeType === 1 || this.nodeType === 11 ) {
+ if ( !isDisconnected( this ) && this.nodeType === 1 || this.nodeType === 11 ) {
next = this.nextSibling;
parent = this.parentNode;