aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2016-08-02 16:41:34 -0400
committerDave Methvin <dave.methvin@gmail.com>2016-08-10 10:04:24 -0400
commit560c0c6f995a4f7584dac5be8fe5eea114a95f69 (patch)
tree36db0299b2c8833075eca4f0915717aaea44ea54 /test
parentcca2aa2254e805612d12bca457afefa920d0af5c (diff)
downloadjquery-560c0c6f995a4f7584dac5be8fe5eea114a95f69.tar.gz
jquery-560c0c6f995a4f7584dac5be8fe5eea114a95f69.zip
Traversing: Let .not(arraylike) pass non-element nodes
Fixes gh-3226 Closes gh-3261
Diffstat (limited to 'test')
-rw-r--r--test/unit/traversing.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 74da6d973..c7ed01415 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -481,6 +481,20 @@ QUnit.test( "not(Selector) excludes non-element nodes (gh-2808)", function( asse
assert.deepEqual( mixedContents.not( "[id=a],*,[id=b]" ).get(), [], "not [id=a],*,[id=b]" );
} );
+QUnit.test( "not(arraylike) passes non-element nodes (gh-3226)", function( assert ) {
+ assert.expect( 5 );
+
+ var mixedContents = jQuery( "<span id='nonnodesElement'>hi</span> there <!-- mon ami -->" ),
+ mixedLength = mixedContents.length,
+ firstElement = mixedContents.first();
+
+ assert.deepEqual( mixedContents.not( mixedContents ).get(), [], "not everything" );
+ assert.deepEqual( mixedContents.not( firstElement ).length, mixedLength - 1, "not firstElement" );
+ assert.deepEqual( mixedContents.not( [ firstElement[ 0 ].nextSibling ] ).length, mixedLength - 1, "not textnode array" );
+ assert.deepEqual( mixedContents.not( firstElement[ 0 ].nextSibling ).length, mixedLength - 1, "not textnode" );
+ assert.deepEqual( mixedContents.not( document.body ).get(), mixedContents.get(), "not with unmatched element" );
+} );
+
QUnit.test( "has(Element)", function( assert ) {
assert.expect( 3 );
var obj, detached, multipleParent;