diff --git a/sizzle.js b/sizzle.js index aa002867..ac01c043 100644 --- a/sizzle.js +++ b/sizzle.js @@ -1373,11 +1373,16 @@ 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 +1429,8 @@ if ( document.querySelectorAll ) { } }); - rbuggyQSA = 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, @@ -1490,7 +1496,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 ) {