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

Function select

notes/docsify/unpkg/gotop/jquery-2.1.0.js:2430–2492  ·  view source on GitHub ↗
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

2428}
2429
2430function select( selector, context, results, seed ) {
2431 var i, tokens, token, type, find,
2432 match = tokenize( selector );
2433
2434 if ( !seed ) {
2435 // Try to minimize operations if there is only one group
2436 if ( match.length === 1 ) {
2437
2438 // Take a shortcut and set the context if the root selector is an ID
2439 tokens = match[0] = match[0].slice( 0 );
2440 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2441 support.getById && context.nodeType === 9 && documentIsHTML &&
2442 Expr.relative[ tokens[1].type ] ) {
2443
2444 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2445 if ( !context ) {
2446 return results;
2447 }
2448 selector = selector.slice( tokens.shift().value.length );
2449 }
2450
2451 // Fetch a seed set for right-to-left matching
2452 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2453 while ( i-- ) {
2454 token = tokens[i];
2455
2456 // Abort if we hit a combinator
2457 if ( Expr.relative[ (type = token.type) ] ) {
2458 break;
2459 }
2460 if ( (find = Expr.find[ type ]) ) {
2461 // Search, expanding context for leading sibling combinators
2462 if ( (seed = find(
2463 token.matches[0].replace( runescape, funescape ),
2464 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2465 )) ) {
2466
2467 // If seed is empty or no tokens remain, we can return early
2468 tokens.splice( i, 1 );
2469 selector = seed.length && toSelector( tokens );
2470 if ( !selector ) {
2471 push.apply( results, seed );
2472 return results;
2473 }
2474
2475 break;
2476 }
2477 }
2478 }
2479 }
2480 }
2481
2482 // Compile and execute a filtering function
2483 // Provide `match` to avoid retokenization if we modified the selector above
2484 compile( selector, match )(
2485 seed,
2486 context,
2487 !documentIsHTML,

Callers 1

SizzleFunction · 0.85

Calls 3

tokenizeFunction · 0.85
testContextFunction · 0.85
toSelectorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…