]> source.dussan.org Git - jquery.git/commitdiff
Update Sizzle and add tests from the Sizzle suite that require jQuery for the selecti...
authortimmywil <timmywillisn@gmail.com>
Mon, 28 May 2012 16:18:40 +0000 (12:18 -0400)
committertimmywil <timmywillisn@gmail.com>
Mon, 28 May 2012 16:41:58 +0000 (12:41 -0400)
src/sizzle
test/index.html
test/unit/selector.js

index feebbd7e053bff426444c7b348c776c99c7490ee..5e4e75511d1238a8924dace6982401ab0c253202 160000 (submodule)
@@ -1 +1 @@
-Subproject commit feebbd7e053bff426444c7b348c776c99c7490ee
+Subproject commit 5e4e75511d1238a8924dace6982401ab0c253202
index c1320ccad05610ea937cd625b59f6f79e7091504..62b633c78cb5ba2620f01afc323d27c00f3b0659 100644 (file)
@@ -33,7 +33,7 @@
        <script src="unit/exports.js"></script>
 
        <script>
-       // html5shiv, enabling HTML5 elements to be used with jQuery
+               // html5shiv, enabling HTML5 elements to be used with jQuery
                ( "abbr article aside audio bdi canvas data details figcaption figure footer header hgroup " +
                        "mark meter nav output progress section summary time video"
                ).replace(/\w+/g, function(n) {
index a5758a1c795e5c8879b9f95cb938574cf798d37c..18089c8c5845293ae2875cddd3e1adaf93827a61 100644 (file)
@@ -1,11 +1,63 @@
 /**
- * This test page is for selector tests that address selector issues that have already been addressed in jQuery functions
- *   and which only work because jQuery has hooked into Sizzle.
- * These tests may or may not fail in an independent Sizzle.
+ * This test page is for selector tests that require jQuery in order to do the selection
  */
 
 module("selector - jQuery only", { teardown: moduleTeardown });
 
+test("element - jQuery only", function() {
+       expect( 5 );
+
+       deepEqual( jQuery("p", document.getElementsByTagName("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+       deepEqual( jQuery("p", "div").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+       deepEqual( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+       deepEqual( jQuery("div").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+
+       //#7533
+       equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
+});
+
+test("class - jQuery only", function() {
+       expect( 4 );
+
+       deepEqual( jQuery(".blog", document.getElementsByTagName("p")).get(), q("mark", "simon"), "Finding elements with a context." );
+       deepEqual( jQuery(".blog", "p").get(), q("mark", "simon"), "Finding elements with a context." );
+       deepEqual( jQuery(".blog", jQuery("p")).get(), q("mark", "simon"), "Finding elements with a context." );
+       deepEqual( jQuery("p").find(".blog").get(), q("mark", "simon"), "Finding elements with a context." );
+});
+
+test("pseudo - visibility", function() {
+       expect(9);
+
+       t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
+       t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
+       t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
+
+       var $div = jQuery('<div/>').appendTo("body");
+       $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0
+       $div.width(1).height(0);
+       t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+       t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+       $div.width(0).height(1);
+       t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+       t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+       $div.width(1).height(1);
+       t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+       t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+       $div.remove();
+});
+
+test("disconnected nodes", function() {
+       expect(4);
+       var $opt = jQuery('<option></option>').attr("value", "whipit").appendTo("#qunit-fixture").detach();
+       equal( $opt.val(), "whipit", "option value" );
+       equal( $opt.is(":selected"), false, "unselected option" );
+       $opt.attr("selected", true);
+       equal( $opt.is(":selected"), true, "selected option" );
+
+       var $div = jQuery( '<div/>' );
+       equal( $div.is("div"), true, "Make sure .is('nodeName') works on disconnect nodes." );
+});
+
 testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
        expect(34);