Commit 2eda329b authored by Dave Methvin's avatar Dave Methvin

Ref #13019 and gh-1062. Use parentNode check instead of isDisconnected().

parent f8f52cfc
...@@ -141,7 +141,7 @@ jQuery.fn.extend({ ...@@ -141,7 +141,7 @@ jQuery.fn.extend({
before: function() { before: function() {
return this.domManip( arguments, false, function( elem ) { return this.domManip( arguments, false, function( elem ) {
if ( !isDisconnected( this ) ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
} }
}); });
...@@ -149,7 +149,7 @@ jQuery.fn.extend({ ...@@ -149,7 +149,7 @@ jQuery.fn.extend({
after: function() { after: function() {
return this.domManip( arguments, false, function( elem ) { return this.domManip( arguments, false, function( elem ) {
if ( !isDisconnected( this ) ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
} }
}); });
...@@ -258,12 +258,11 @@ jQuery.fn.extend({ ...@@ -258,12 +258,11 @@ jQuery.fn.extend({
} }
return this.domManip( [ value ], true, function( elem ) { return this.domManip( [ value ], true, function( elem ) {
var next, parent; var next = this.nextSibling,
if ( !isDisconnected( this ) && this.nodeType === 1 || this.nodeType === 11 ) {
next = this.nextSibling;
parent = this.parentNode; parent = this.parentNode;
if ( parent && this.nodeType === 1 || this.nodeType === 11 ) {
jQuery( this ).remove(); jQuery( this ).remove();
if ( next ) { if ( next ) {
......
...@@ -131,12 +131,6 @@ jQuery.fn.extend({ ...@@ -131,12 +131,6 @@ jQuery.fn.extend({
jQuery.fn.andSelf = jQuery.fn.addBack; jQuery.fn.andSelf = jQuery.fn.addBack;
// A painfully simple check to see if an element is disconnected
// from a document (should be improved, where feasible).
function isDisconnected( node ) {
return !node || !node.parentNode || node.parentNode.nodeType === 11;
}
function sibling( cur, dir ) { function sibling( cur, dir ) {
do { do {
cur = cur[ dir ]; cur = cur[ dir ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment