aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-01-13 00:12:18 -0500
committerjeresig <jeresig@gmail.com>2010-01-13 00:12:18 -0500
commit5d49335eace4311de890b871e057d8b6e9122eb6 (patch)
tree4a587dfdc3595eb0ce23f7a4d606b963ff879e01 /src
parent8e53f7b5d6716e60d8c8ea7e167f2b187aae9d89 (diff)
downloadjquery-5d49335eace4311de890b871e057d8b6e9122eb6.tar.gz
jquery-5d49335eace4311de890b871e057d8b6e9122eb6.zip
Make sure that disconnected nodes aren't sorted/uniqued. Fixes #5791.
Diffstat (limited to 'src')
-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;