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 | |
parent | f8b27f16ba748627fd8e56965047d6d1ebd90b4b (diff) | |
download | jquery-4ef516903e6e48bce388ca47c1ed88a447199fa1.tar.gz jquery-4ef516903e6e48bce388ca47c1ed88a447199fa1.zip |
Fix #13539: Utilize Sizzle hooks. Close gh-1215.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/css.js | 4 | ||||
-rw-r--r-- | test/unit/selector.js | 9 | ||||
-rw-r--r-- | test/unit/traversing.js | 39 |
3 files changed, 38 insertions, 14 deletions
diff --git a/test/unit/css.js b/test/unit/css.js index 14596c347..027cda9e4 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -904,8 +904,8 @@ test( ":visible/:hidden selectors", function() { ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden" ); jQuery("#nothiddendiv").css({"display": "block"}); ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible"); - ok( jQuery(window).is(":visible"), "Calling is(':visible') on window does not throw an error in IE."); - ok( jQuery(document).is(":visible"), "Calling is(':visible') on document does not throw an error in IE."); + ok( jQuery(window).is(":visible") || true, "Calling is(':visible') on window does not throw an exception (#10267)"); + ok( jQuery(document).is(":visible") || true, "Calling is(':visible') on document does not throw an exception (#10267)"); ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible"); jQuery("#nothiddendiv").css("display", "none"); diff --git a/test/unit/selector.js b/test/unit/selector.js index 0cfba2834..440e7167b 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -31,17 +31,10 @@ test("class - jQuery only", function() { }); test("attributes - jQuery only", function() { - expect( 6 ); + expect( 5 ); t( "Find elements with a tabindex attribute", "[tabindex]", ["listWithTabIndex", "foodWithNegativeTabIndex", "linkWithTabIndex", "linkWithNegativeTabIndex", "linkWithNoHrefWithTabIndex", "linkWithNoHrefWithNegativeTabIndex"] ); - // #12523 - deepEqual( - jQuery.find( "[title]", null, null, jQuery("#qunit-fixture a").get().concat( document.createTextNode("") ) ), - q("google"), - "Text nodes fail attribute tests without exception" - ); - // #12600 ok( jQuery("<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>") 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" ); +}); |