Skip to content
Permalink
Browse files

Update Sizzle and add tests from the Sizzle suite that require jQuery…

… for the selection to jquery/test/unit/selector.js
  • Loading branch information...
timmywil committed May 28, 2012
1 parent d0763a3 commit a4fc2edaab8c92bfebf90a10bd3f23dc7e03f993
Showing with 57 additions and 5 deletions.
  1. +1 −1 src/sizzle
  2. +1 −1 test/index.html
  3. +55 −3 test/unit/selector.js
Submodule sizzle updated 3 files
+337 −413 sizzle.js
+1 −1 test/data/testinit.js
+89 −117 test/unit/selector.js
@@ -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) {
@@ -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);

0 comments on commit a4fc2ed

Please sign in to comment.
You can’t perform that action at this time.