diff --git a/src/sizzle b/src/sizzle
index 3ffd629e3..f56f17849 160000
--- a/src/sizzle
+++ b/src/sizzle
@@ -1 +1 @@
-Subproject commit 3ffd629e38c3a1cc31febc010718c985a4f85a4d
+Subproject commit f56f1784961a63f4118e43b1441ffc2f32ef5d41
diff --git a/test/data/selector.html b/test/data/selector/html5_selector.html
similarity index 64%
rename from test/data/selector.html
rename to test/data/selector/html5_selector.html
index 8ffc6c6b3..28aa2b607 100644
--- a/test/data/selector.html
+++ b/test/data/selector/html5_selector.html
@@ -2,28 +2,28 @@
- jQuery selector
+ jQuery selector - attributes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/selector.js b/test/unit/selector.js
index 441258008..2c9dcec83 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -17,7 +17,7 @@ var testIframe = function( fileName, name, fn ) {
var loadFixture = function() {
// Creates iframe with cache disabled
- var src = "./data/" + fileName + ".html?" + parseInt( Math.random()*1000, 10 ),
+ var src = "./data/selector/" + fileName + ".html?" + parseInt( Math.random()*1000, 10 ),
iframe = jQuery("").css({
width: 500, height: 500, position: "absolute", top: -600, left: -600, visibility: "hidden"
}).appendTo("body")[0];
@@ -38,7 +38,7 @@ var testIframe = function( fileName, name, fn ) {
// continue
start();
// call actual tests passing the correct jQuery instance to use
- fn.call( this, win.jQuery, win );
+ fn.call( this, win.jQuery, win, win.document );
document.body.removeChild( iframe );
iframe = null;
}
@@ -46,23 +46,21 @@ var testIframe = function( fileName, name, fn ) {
});
};
-testIframe("selector", "attributes - jQuery.attr", function( jQuery, window ) {
+testIframe("html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
expect(34);
- var document = window.document;
-
/**
* Returns an array of elements with the given IDs, eg.
*/
- var q = function() {
- var r = [];
-
- for ( var i = 0; i < arguments.length; i++ ) {
- r.push( document.getElementById( arguments[i] ) );
- }
-
- return r;
- };
+ function q() {
+ var r = [],
+ i = 0;
+
+ for ( ; i < arguments.length; i++ ) {
+ r.push( document.getElementById( arguments[i] ) );
+ }
+ return r;
+ }
/**
* Asserts that a select matches the given IDs * @example t("Check for something", "//[a]", ["foo", "baar"]);
@@ -70,15 +68,17 @@ testIframe("selector", "attributes - jQuery.attr", function( jQuery, window ) {
* @param {String} b - Sizzle selector
* @param {String} c - Array of ids to construct what is expected
*/
- var t = function( a, b, c ) {
- var f = jQuery(b).get(), s = "";
+ function t( a, b, c ) {
+ var f = jQuery(b).get(),
+ s = "",
+ i = 0;
- for ( var i = 0; i < f.length; i++ ) {
- s += (s && ",") + '"' + f[i].id + '"';
+ for ( ; i < f.length; i++ ) {
+ s += (s && ",") + '"' + f[i].id + '"';
}
deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
- };
+ }
// ====== All known boolean attributes, including html5 booleans ======
// autobuffer, autofocus, autoplay, async, checked,
@@ -131,3 +131,12 @@ testIframe("selector", "attributes - jQuery.attr", function( jQuery, window ) {
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"]);
});
+
+testIframe("sizzle_cache", "Sizzle cache collides with multiple Sizzles on a page", function( jQuery, window, document ) {
+ var $git = window.$git;
+
+ expect(3);
+ deepEqual( $git('.test a').get(), [ document.getElementById('collision') ], "Select collision anchor with first sizzle" );
+ equal( jQuery('.evil a').length, 0, "Select nothing with second sizzle" );
+ equal( jQuery('.evil a').length, 0, "Select nothing again with second sizzle" );
+});