Fix #10517. before() and after() on disconnected node should return multiple nodes. Closes gh-851.

This commit is contained in:
Uri Gilad
2012-07-10 10:14:43 -04:00
committed by Dave Methvin
parent b6cb4b420f
commit f843a7062f
2 changed files with 10 additions and 3 deletions

View File

@@ -142,7 +142,7 @@ jQuery.fn.extend({
},
before: function() {
if ( this[0] && this[0].parentNode ) {
if ( !isDisconnected( this[0] ) ) {
return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this );
});
@@ -155,7 +155,7 @@ jQuery.fn.extend({
},
after: function() {
if ( this[0] && this[0].parentNode ) {
if ( !isDisconnected( this[0] ) ) {
return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this.nextSibling );
});
@@ -259,7 +259,7 @@ jQuery.fn.extend({
},
replaceWith: function( value ) {
if ( this[0] && this[0].parentNode && this[0].parentNode.nodeType != 11 ) {
if ( !isDisconnected( this[0] ) ) {
// 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 ) ) {