( tokens )
| 2372 | } |
| 2373 | |
| 2374 | function matcherFromTokens( tokens ) { |
| 2375 | var checkContext, matcher, j, |
| 2376 | len = tokens.length, |
| 2377 | leadingRelative = Expr.relative[ tokens[ 0 ].type ], |
| 2378 | implicitRelative = leadingRelative || Expr.relative[ " " ], |
| 2379 | i = leadingRelative ? 1 : 0, |
| 2380 | |
| 2381 | // The foundational matcher ensures that elements are reachable from top-level context(s) |
| 2382 | matchContext = addCombinator( function( elem ) { |
| 2383 | return elem === checkContext; |
| 2384 | }, implicitRelative, true ), |
| 2385 | matchAnyContext = addCombinator( function( elem ) { |
| 2386 | return indexOf.call( checkContext, elem ) > -1; |
| 2387 | }, implicitRelative, true ), |
| 2388 | matchers = [ function( elem, context, xml ) { |
| 2389 | |
| 2390 | // Support: IE 11+, Edge 17 - 18+ |
| 2391 | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
| 2392 | // two documents; shallow comparisons work. |
| 2393 | // eslint-disable-next-line eqeqeq |
| 2394 | var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || ( |
| 2395 | ( checkContext = context ).nodeType ? |
| 2396 | matchContext( elem, context, xml ) : |
| 2397 | matchAnyContext( elem, context, xml ) ); |
| 2398 | |
| 2399 | // Avoid hanging onto element |
| 2400 | // (see https://github.com/jquery/sizzle/issues/299) |
| 2401 | checkContext = null; |
| 2402 | return ret; |
| 2403 | } ]; |
| 2404 | |
| 2405 | for ( ; i < len; i++ ) { |
| 2406 | if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { |
| 2407 | matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; |
| 2408 | } else { |
| 2409 | matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); |
| 2410 | |
| 2411 | // Return special upon seeing a positional matcher |
| 2412 | if ( matcher[ expando ] ) { |
| 2413 | |
| 2414 | // Find the next relative operator (if any) for proper handling |
| 2415 | j = ++i; |
| 2416 | for ( ; j < len; j++ ) { |
| 2417 | if ( Expr.relative[ tokens[ j ].type ] ) { |
| 2418 | break; |
| 2419 | } |
| 2420 | } |
| 2421 | return setMatcher( |
| 2422 | i > 1 && elementMatcher( matchers ), |
| 2423 | i > 1 && toSelector( |
| 2424 | |
| 2425 | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
| 2426 | tokens.slice( 0, i - 1 ) |
| 2427 | .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) |
| 2428 | ).replace( rtrimCSS, "$1" ), |
| 2429 | matcher, |
| 2430 | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
| 2431 | j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), |
no test coverage detected