MCPcopy Index your code
hub / github.com/frank-lam/fullstack-tutorial / matcherFromTokens

Function matcherFromTokens

notes/docsify/unpkg/gotop/jquery-2.1.0.js:2240–2293  ·  view source on GitHub ↗
( tokens )

Source from the content-addressed store, hash-verified

2238}
2239
2240function matcherFromTokens( tokens ) {
2241 var checkContext, matcher, j,
2242 len = tokens.length,
2243 leadingRelative = Expr.relative[ tokens[0].type ],
2244 implicitRelative = leadingRelative || Expr.relative[" "],
2245 i = leadingRelative ? 1 : 0,
2246
2247 // The foundational matcher ensures that elements are reachable from top-level context(s)
2248 matchContext = addCombinator( function( elem ) {
2249 return elem === checkContext;
2250 }, implicitRelative, true ),
2251 matchAnyContext = addCombinator( function( elem ) {
2252 return indexOf.call( checkContext, elem ) > -1;
2253 }, implicitRelative, true ),
2254 matchers = [ function( elem, context, xml ) {
2255 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2256 (checkContext = context).nodeType ?
2257 matchContext( elem, context, xml ) :
2258 matchAnyContext( elem, context, xml ) );
2259 } ];
2260
2261 for ( ; i < len; i++ ) {
2262 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2263 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2264 } else {
2265 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2266
2267 // Return special upon seeing a positional matcher
2268 if ( matcher[ expando ] ) {
2269 // Find the next relative operator (if any) for proper handling
2270 j = ++i;
2271 for ( ; j < len; j++ ) {
2272 if ( Expr.relative[ tokens[j].type ] ) {
2273 break;
2274 }
2275 }
2276 return setMatcher(
2277 i > 1 && elementMatcher( matchers ),
2278 i > 1 && toSelector(
2279 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2280 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2281 ).replace( rtrim, "$1" ),
2282 matcher,
2283 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2284 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2285 j < len && toSelector( tokens )
2286 );
2287 }
2288 matchers.push( matcher );
2289 }
2290 }
2291
2292 return elementMatcher( matchers );
2293}
2294
2295function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2296 var bySet = setMatchers.length > 0,

Callers 1

jquery-2.1.0.jsFile · 0.85

Calls 4

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…