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-05 00:37:36 -0400 |
commit | 5d1dfe747403c093cc0e837651dcf80027387fc6 (patch) | |
tree | 44cc433e2d2a3e496443128025983b39205c5822 /test | |
parent | 6358da8aa32e7ed52da3af1a912bdd1a05863faf (diff) | |
download | jquery-5d1dfe747403c093cc0e837651dcf80027387fc6.tar.gz jquery-5d1dfe747403c093cc0e837651dcf80027387fc6.zip |
Fix #13539: Utilize Sizzle hooks. Close gh-1215.
(cherry picked from commit 4ef516903e6e48bce388ca47c1ed88a447199fa1)
Diffstat (limited to 'test')
-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 e8ce75b02..dc851f745 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -864,8 +864,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 0e6439300..1060e7e40 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() { @@ -716,3 +735,15 @@ test("index(no arg) #10977", function() { equal( jQuery( div ).index(), 0, "If jQuery#index called on element whose parent is fragment, it still should work correctly" ); }); + +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" ); +}); |