aboutsummaryrefslogtreecommitdiffstats
path: root/src/manipulation.js
diff options
context:
space:
mode:
authorNoah Sloan <noah.sloan@gmail.com>2010-02-01 21:48:05 -0500
committerjeresig <jeresig@gmail.com>2010-02-01 21:48:05 -0500
commit8660ea1ab61dd16aec1ed24ec549c6258292b96a (patch)
treead013af49b7b105cd9df6f57f18cb6a47ddba865 /src/manipulation.js
parente76ba32cebc26108e15b2e0e03c5152624c1bad9 (diff)
downloadjquery-8660ea1ab61dd16aec1ed24ec549c6258292b96a.tar.gz
jquery-8660ea1ab61dd16aec1ed24ec549c6258292b96a.zip
Only detach the incoming elements to replaceWith if they're DOM nodes. Fixes #5986.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r--src/manipulation.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 2dccc7592..6f0373daa 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -268,16 +268,17 @@ jQuery.fn.extend({
if ( this[0] && this[0].parentNode ) {
// Make sure that the elements are removed from the DOM before they are inserted
// this can help fix replacing a parent with child elements
- if ( !jQuery.isFunction( value ) ) {
- value = jQuery( value ).detach();
-
- } else {
+ if ( jQuery.isFunction( value ) ) {
return this.each(function(i) {
var self = jQuery(this), old = self.html();
self.replaceWith( value.call( this, i, old ) );
});
}
+ if ( typeof value !== "string" ) {
+ value = jQuery(value).detach();
+ }
+
return this.each(function() {
var next = this.nextSibling, parent = this.parentNode;