Skip to content

Commit

Permalink
Selector: Prevent seeded invocations from cutting off the qSA path
Browse files Browse the repository at this point in the history
Fixes gh-393
Closes gh-396
  • Loading branch information
gibson042 committed Dec 2, 2016
1 parent 0a60995 commit eabce51
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
12 changes: 8 additions & 4 deletions dist/sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Released under the MIT license
* https://js.foundation/
*
* Date: 2016-11-20
* Date: 2016-12-02
*/
(function( window ) {

Expand Down Expand Up @@ -40,6 +40,7 @@ var i,
classCache = createCache(),
tokenCache = createCache(),
compilerCache = createCache(),
nonnativeSelectorCache = createCache(),
sortOrder = function( a, b ) {
if ( a === b ) {
hasDuplicate = true;
Expand Down Expand Up @@ -292,7 +293,7 @@ function Sizzle( selector, context, results, seed ) {

// Take advantage of querySelectorAll
if ( support.qsa &&
!compilerCache[ selector + " " ] &&
!nonnativeSelectorCache[ selector + " " ] &&
(!rbuggyQSA || !rbuggyQSA.test( selector )) ) {

if ( nodeType !== 1 ) {
Expand Down Expand Up @@ -332,6 +333,7 @@ function Sizzle( selector, context, results, seed ) {
);
return results;
} catch ( qsaError ) {
nonnativeSelectorCache( selector );
} finally {
if ( nid === expando ) {
context.removeAttribute( "id" );
Expand Down Expand Up @@ -985,7 +987,7 @@ Sizzle.matchesSelector = function( elem, expr ) {
expr = expr.replace( rattributeQuotes, "='$1']" );

if ( support.matchesSelector && documentIsHTML &&
!compilerCache[ expr + " " ] &&
!nonnativeSelectorCache[ expr + " " ] &&
( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {

Expand All @@ -999,7 +1001,9 @@ Sizzle.matchesSelector = function( elem, expr ) {
elem.document && elem.document.nodeType !== 11 ) {
return ret;
}
} catch (e) {}
} catch (e) {
nonnativeSelectorCache( expr );
}
}

return Sizzle( expr, document, null, [ elem ] ).length > 0;
Expand Down
Loading

0 comments on commit eabce51

Please sign in to comment.