MCPcopy Create free account
hub / github.com/TruthHun/BookStack / matcherFromTokens

Function matcherFromTokens

static/wangEditor/js/lib/jquery-2.2.1.js:2330–2386  ·  view source on GitHub ↗
( tokens )

Source from the content-addressed store, hash-verified

2328}
2329
2330function matcherFromTokens( tokens ) {
2331 var checkContext, matcher, j,
2332 len = tokens.length,
2333 leadingRelative = Expr.relative[ tokens[0].type ],
2334 implicitRelative = leadingRelative || Expr.relative[" "],
2335 i = leadingRelative ? 1 : 0,
2336
2337 // The foundational matcher ensures that elements are reachable from top-level context(s)
2338 matchContext = addCombinator( function( elem ) {
2339 return elem === checkContext;
2340 }, implicitRelative, true ),
2341 matchAnyContext = addCombinator( function( elem ) {
2342 return indexOf( checkContext, elem ) > -1;
2343 }, implicitRelative, true ),
2344 matchers = [ function( elem, context, xml ) {
2345 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2346 (checkContext = context).nodeType ?
2347 matchContext( elem, context, xml ) :
2348 matchAnyContext( elem, context, xml ) );
2349 // Avoid hanging onto element (issue #299)
2350 checkContext = null;
2351 return ret;
2352 } ];
2353
2354 for ( ; i < len; i++ ) {
2355 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2356 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2357 } else {
2358 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2359
2360 // Return special upon seeing a positional matcher
2361 if ( matcher[ expando ] ) {
2362 // Find the next relative operator (if any) for proper handling
2363 j = ++i;
2364 for ( ; j < len; j++ ) {
2365 if ( Expr.relative[ tokens[j].type ] ) {
2366 break;
2367 }
2368 }
2369 return setMatcher(
2370 i > 1 && elementMatcher( matchers ),
2371 i > 1 && toSelector(
2372 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2373 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2374 ).replace( rtrim, "$1" ),
2375 matcher,
2376 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2377 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2378 j < len && toSelector( tokens )
2379 );
2380 }
2381 matchers.push( matcher );
2382 }
2383 }
2384
2385 return elementMatcher( matchers );
2386}
2387

Callers 1

jquery-2.2.1.jsFile · 0.70

Calls 5

addCombinatorFunction · 0.70
indexOfFunction · 0.70
elementMatcherFunction · 0.70
setMatcherFunction · 0.70
toSelectorFunction · 0.70

Tested by

no test coverage detected