MCPcopy Index your code
hub / github.com/caike/jQuery-Simple-Timer / matcherFromTokens

Function matcherFromTokens

examples/bundle.js:2629–2685  ·  view source on GitHub ↗
( tokens )

Source from the content-addressed store, hash-verified

2627}
2628
2629function matcherFromTokens( tokens ) {
2630 var checkContext, matcher, j,
2631 len = tokens.length,
2632 leadingRelative = Expr.relative[ tokens[0].type ],
2633 implicitRelative = leadingRelative || Expr.relative[" "],
2634 i = leadingRelative ? 1 : 0,
2635
2636 // The foundational matcher ensures that elements are reachable from top-level context(s)
2637 matchContext = addCombinator( function( elem ) {
2638 return elem === checkContext;
2639 }, implicitRelative, true ),
2640 matchAnyContext = addCombinator( function( elem ) {
2641 return indexOf( checkContext, elem ) > -1;
2642 }, implicitRelative, true ),
2643 matchers = [ function( elem, context, xml ) {
2644 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2645 (checkContext = context).nodeType ?
2646 matchContext( elem, context, xml ) :
2647 matchAnyContext( elem, context, xml ) );
2648 // Avoid hanging onto element (issue #299)
2649 checkContext = null;
2650 return ret;
2651 } ];
2652
2653 for ( ; i < len; i++ ) {
2654 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2655 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2656 } else {
2657 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2658
2659 // Return special upon seeing a positional matcher
2660 if ( matcher[ expando ] ) {
2661 // Find the next relative operator (if any) for proper handling
2662 j = ++i;
2663 for ( ; j < len; j++ ) {
2664 if ( Expr.relative[ tokens[j].type ] ) {
2665 break;
2666 }
2667 }
2668 return setMatcher(
2669 i > 1 && elementMatcher( matchers ),
2670 i > 1 && toSelector(
2671 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2672 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2673 ).replace( rtrim, "$1" ),
2674 matcher,
2675 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2676 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2677 j < len && toSelector( tokens )
2678 );
2679 }
2680 matchers.push( matcher );
2681 }
2682 }
2683
2684 return elementMatcher( matchers );
2685}
2686

Callers 1

bundle.jsFile · 0.85

Calls 5

addCombinatorFunction · 0.85
indexOfFunction · 0.85
elementMatcherFunction · 0.85
setMatcherFunction · 0.85
toSelectorFunction · 0.85

Tested by

no test coverage detected