Skip to content

Commit 2eda329

Browse files
committed
Ref #13019 and jquerygh-1062. Use parentNode check instead of isDisconnected().
1 parent f8f52cf commit 2eda329

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/manipulation.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ jQuery.fn.extend({
141141

142142
before: function() {
143143
return this.domManip( arguments, false, function( elem ) {
144-
if ( !isDisconnected( this ) ) {
144+
if ( this.parentNode ) {
145145
this.parentNode.insertBefore( elem, this );
146146
}
147147
});
148148
},
149149

150150
after: function() {
151151
return this.domManip( arguments, false, function( elem ) {
152-
if ( !isDisconnected( this ) ) {
152+
if ( this.parentNode ) {
153153
this.parentNode.insertBefore( elem, this.nextSibling );
154154
}
155155
});
@@ -258,12 +258,11 @@ jQuery.fn.extend({
258258
}
259259

260260
return this.domManip( [ value ], true, function( elem ) {
261-
var next, parent;
262-
263-
if ( !isDisconnected( this ) && this.nodeType === 1 || this.nodeType === 11 ) {
264-
next = this.nextSibling;
261+
var next = this.nextSibling,
265262
parent = this.parentNode;
266263

264+
if ( parent && this.nodeType === 1 || this.nodeType === 11 ) {
265+
267266
jQuery( this ).remove();
268267

269268
if ( next ) {

src/traversing.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ jQuery.fn.extend({
131131

132132
jQuery.fn.andSelf = jQuery.fn.addBack;
133133

134-
// A painfully simple check to see if an element is disconnected
135-
// from a document (should be improved, where feasible).
136-
function isDisconnected( node ) {
137-
return !node || !node.parentNode || node.parentNode.nodeType === 11;
138-
}
139-
140134
function sibling( cur, dir ) {
141135
do {
142136
cur = cur[ dir ];

0 commit comments

Comments
 (0)