From 2eda329be6ac2f68e9b313ee607ea24165c68755 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Sun, 9 Dec 2012 14:45:31 -0500 Subject: [PATCH] Ref #13019 and gh-1062. Use parentNode check instead of isDisconnected(). --- src/manipulation.js | 11 +++++------ src/traversing.js | 6 ------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/manipulation.js b/src/manipulation.js index c19217c43..992696a0b 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -141,7 +141,7 @@ jQuery.fn.extend({ before: function() { return this.domManip( arguments, false, function( elem ) { - if ( !isDisconnected( this ) ) { + if ( this.parentNode ) { this.parentNode.insertBefore( elem, this ); } }); @@ -149,7 +149,7 @@ jQuery.fn.extend({ after: function() { return this.domManip( arguments, false, function( elem ) { - if ( !isDisconnected( this ) ) { + if ( this.parentNode ) { this.parentNode.insertBefore( elem, this.nextSibling ); } }); @@ -258,12 +258,11 @@ jQuery.fn.extend({ } return this.domManip( [ value ], true, function( elem ) { - var next, parent; - - if ( !isDisconnected( this ) && this.nodeType === 1 || this.nodeType === 11 ) { - next = this.nextSibling; + var next = this.nextSibling, parent = this.parentNode; + if ( parent && this.nodeType === 1 || this.nodeType === 11 ) { + jQuery( this ).remove(); if ( next ) { diff --git a/src/traversing.js b/src/traversing.js index e9b702c3d..99c381010 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -131,12 +131,6 @@ jQuery.fn.extend({ 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 ) { do { cur = cur[ dir ]; -- 2.39.5