]> source.dussan.org Git - jquery.git/commitdiff
Ref #13019 and gh-1062. Use parentNode check instead of isDisconnected().
authorDave Methvin <dave.methvin@gmail.com>
Sun, 9 Dec 2012 19:45:31 +0000 (14:45 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Sun, 9 Dec 2012 19:46:06 +0000 (14:46 -0500)
src/manipulation.js
src/traversing.js

index c19217c43e54b3466d61133e62258b92e587e6b4..992696a0b983175f0d28ea91f991a314eb18a68a 100644 (file)
@@ -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 ) {
index e9b702c3dce1b750860556e57ff3f01bb7bdecf0..99c38101002e4f49bd3c5bfe0fba1aa9dd900a56 100644 (file)
@@ -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 ];