From 26853ee375b75294da6c543fdbb5e5cc76d7daec Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 9 Sep 2012 13:11:05 -0400 Subject: [PATCH 1/3] fixes #12492, is(:focus) fails in Chrome --- sizzle.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sizzle.js b/sizzle.js index aa002867..b015b509 100644 --- a/sizzle.js +++ b/sizzle.js @@ -638,7 +638,6 @@ Expr = Sizzle.selectors = { if ( first === 0 ) { return diff === 0; - } else { return ( diff % first === 0 && diff / first >= 0 ); } @@ -1373,11 +1372,15 @@ if ( document.querySelectorAll ) { oldSelect = select, rescape = /'|\\/g, rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, - rbuggyQSA = [], + + // qSa(:focus) reports false when true (Chrome 21), + // A support test would require too much code (would include document ready) + rbuggyQSA = [":focus"], + // matchesSelector(:focus) reports false when true (Chrome 21), // matchesSelector(:active) reports false when true (IE9/Opera 11.5) // A support test would require too much code (would include document ready) // just skip matchesSelector for :active - rbuggyMatches = [":active"], + rbuggyMatches = [ ":active", ":focus" ], matches = docElem.matchesSelector || docElem.mozMatchesSelector || docElem.webkitMatchesSelector || @@ -1424,7 +1427,8 @@ if ( document.querySelectorAll ) { } }); - rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + // rbuggyMatches always contains :focus, so no need for a length check + rbuggyMatches = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") ); select = function( selector, context, results, seed, xml ) { // Only use querySelectorAll when not filtering, @@ -1490,7 +1494,7 @@ if ( document.querySelectorAll ) { } catch ( e ) {} }); - // rbuggyMatches always contains :active, so no need for a length check + // rbuggyMatches always contains :active and :focus, so no need for a length check rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") ); Sizzle.matchesSelector = function( elem, expr ) { From 0eb0e39631b9cc3a94ae86951f10453b0e27b8f3 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Mon, 10 Sep 2012 12:43:57 -0400 Subject: [PATCH 2/3] style --- sizzle.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sizzle.js b/sizzle.js index b015b509..e3b18ae4 100644 --- a/sizzle.js +++ b/sizzle.js @@ -638,6 +638,7 @@ Expr = Sizzle.selectors = { if ( first === 0 ) { return diff === 0; + } else { return ( diff % first === 0 && diff / first >= 0 ); } @@ -1376,6 +1377,7 @@ if ( document.querySelectorAll ) { // qSa(:focus) reports false when true (Chrome 21), // A support test would require too much code (would include document ready) rbuggyQSA = [":focus"], + // matchesSelector(:focus) reports false when true (Chrome 21), // matchesSelector(:active) reports false when true (IE9/Opera 11.5) // A support test would require too much code (would include document ready) From 893aa32cc847a00e922458b8e0a08314c4e2a4d9 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Mon, 10 Sep 2012 20:40:30 -0400 Subject: [PATCH 3/3] rebased incorrectly --- sizzle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sizzle.js b/sizzle.js index e3b18ae4..ac01c043 100644 --- a/sizzle.js +++ b/sizzle.js @@ -1429,8 +1429,8 @@ if ( document.querySelectorAll ) { } }); - // rbuggyMatches always contains :focus, so no need for a length check - rbuggyMatches = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") ); + // rbuggyQSA always contains :focus, so no need for a length check + rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") ); select = function( selector, context, results, seed, xml ) { // Only use querySelectorAll when not filtering,