diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-03-26 21:20:27 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-04-04 23:04:05 -0400 |
commit | 4ef516903e6e48bce388ca47c1ed88a447199fa1 (patch) | |
tree | 0692b8e14ccc1bb873e43fc1ccbfaacd42b209b2 /test/unit/traversing.js | |
parent | f8b27f16ba748627fd8e56965047d6d1ebd90b4b (diff) | |
download | jquery-4ef516903e6e48bce388ca47c1ed88a447199fa1.tar.gz jquery-4ef516903e6e48bce388ca47c1ed88a447199fa1.zip |
Fix #13539: Utilize Sizzle hooks. Close gh-1215.
Diffstat (limited to 'test/unit/traversing.js')
-rw-r--r-- | test/unit/traversing.js | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js index e0dcd11c8..c4664dda9 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -78,10 +78,29 @@ test("is(String|undefined)", function() { ok( jQuery("#en").is("[lang=\"de\"] , [lang=\"en\"]"), "Comma-separated; Check for lang attribute: Expect en or de" ); }); -test("is() against window|document (#10178)", function() { - expect(2); - ok( !jQuery(window).is("a"), "Checking is on a window does not throw an exception" ); - ok( !jQuery(document).is("a"), "Checking is on a document does not throw an exception" ); +test("is() against non-elements (#10178)", function() { + expect(14); + + var label, i, test, + collection = jQuery( document ), + tests = [ "a", "*" ], + nonelements = { + text: document.createTextNode(""), + comment: document.createComment(""), + document: document, + window: window, + array: [], + "plain object": {}, + "function": function() {} + }; + + for ( label in nonelements ) { + collection[ 0 ] = nonelements[ label ]; + for ( i = 0; i < tests.length; i++ ) { + test = tests[ i ]; + ok( !collection.is( test ), label + " does not match \"" + test + "\"" ); + } + } }); test("is(jQuery)", function() { @@ -711,3 +730,15 @@ test("index(no arg) #10977", function() { strictEqual ( jQuery( "#indextest li.zero" ).first().index() , 0, "No Argument Index Check" ); $list.remove(); }); + +test("traversing non-elements with attribute filters (#12523)", function() { + expect(5); + + var nonnodes = jQuery("#nonnodes").contents(); + + equal( nonnodes.filter("[id]").length, 1, ".filter" ); + equal( nonnodes.find("[id]").length, 0, ".find" ); + strictEqual( nonnodes.is("[id]"), true, ".is" ); + deepEqual( nonnodes.closest("[id='nonnodes']").get(), q("nonnodes"), ".closest" ); + deepEqual( nonnodes.parents("[id='nonnodes']").get(), q("nonnodes"), ".parents" ); +}); |