Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector: Prevent seeded invocations from cutting off the qSA path #396

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions dist/sizzle.js
Expand Up @@ -6,7 +6,7 @@
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-08-15
* Date: 2016-11-20
*/
(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