aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOleg <markelog@gmail.com>2012-03-30 19:56:11 +0400
committerDave Methvin <dave.methvin@gmail.com>2012-04-05 12:53:36 -0400
commitc04bfce556616a60cecf0ecaf9cb1f9d048a4747 (patch)
treeb81f898cc50f973384270d1bf403cd652c17d13b /src
parent4cd57d727a075617c8db30dcf69542f66add63fe (diff)
downloadjquery-c04bfce556616a60cecf0ecaf9cb1f9d048a4747.tar.gz
jquery-c04bfce556616a60cecf0ecaf9cb1f9d048a4747.zip
Fixes #11338, .replaceWith should work on detached nodes.
Diffstat (limited to 'src')
-rw-r--r--src/manipulation.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 7a1cc3b17..43bf37746 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -46,7 +46,7 @@ wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
-// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// unless wrapped in a div with non-breaking characters in front of it.
if ( !jQuery.support.htmlSerialize ) {
wrapMap._default = [ 1, "X<div>", "</div>" ];
@@ -222,7 +222,7 @@ jQuery.fn.extend({
}
// See if we can take a shortcut and just use innerHTML
- if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
@@ -252,7 +252,7 @@ jQuery.fn.extend({
},
replaceWith: function( value ) {
- if ( this[0] && this[0].parentNode ) {
+ if ( this[0] && this[0].parentNode && this[0].parentNode.nodeType != 11 ) {
// 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 ) ) {
@@ -278,11 +278,11 @@ jQuery.fn.extend({
jQuery(parent).append( value );
}
});
- } else {
- return this.length ?
- this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
- this;
}
+
+ return this.length ?
+ this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
+ this;
},
detach: function( selector ) {