Skip to content
Permalink
Browse files
Ref #13019 and gh-1062. Use parentNode check instead of isDisconnecte…
…d().
  • Loading branch information
dmethvin committed Dec 9, 2012
1 parent f8f52cf commit 2eda329
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
@@ -141,15 +141,15 @@ jQuery.fn.extend({

before: function() {
return this.domManip( arguments, false, function( elem ) {
if ( !isDisconnected( this ) ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this );
}
});
},

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 ) {
@@ -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 ];

0 comments on commit 2eda329

Please sign in to comment.