aboutsummaryrefslogtreecommitdiffstats
path: root/src/traversing.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/traversing.js')
-rw-r--r--src/traversing.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/traversing.js b/src/traversing.js
index a09ae1937..d0dd52db8 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -146,9 +146,9 @@ jQuery.fn.extend({
jQuery.makeArray( selector ),
all = jQuery.merge( this.get(), set );
- return this.pushStack( set[0] && (set[0].setInterval || set[0].nodeType === 9 || (set[0].parentNode && set[0].parentNode.nodeType !== 11)) ?
- jQuery.unique( all ) :
- all );
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
},
andSelf: function() {
@@ -156,6 +156,12 @@ jQuery.fn.extend({
}
});
+// 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;
+}
+
jQuery.each({
parent: function( elem ) {
var parent = elem.parentNode;