MCPcopy Index your code
hub / github.com/JsAaron/jQuery / select

Function select

2.0.3/2.0.3.js:2718–2780  ·  view source on GitHub ↗
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

2716 }
2717
2718 function select( selector, context, results, seed ) {
2719 var i, tokens, token, type, find,
2720 match = tokenize( selector );
2721
2722 if ( !seed ) {
2723 // Try to minimize operations if there is only one group
2724 if ( match.length === 1 ) {
2725
2726 // Take a shortcut and set the context if the root selector is an ID
2727 tokens = match[0] = match[0].slice( 0 );
2728 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2729 support.getById && context.nodeType === 9 && documentIsHTML &&
2730 Expr.relative[ tokens[1].type ] ) {
2731
2732 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2733 if ( !context ) {
2734 return results;
2735 }
2736 selector = selector.slice( tokens.shift().value.length );
2737 }
2738
2739 // Fetch a seed set for right-to-left matching
2740 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2741 while ( i-- ) {
2742 token = tokens[i];
2743
2744 // Abort if we hit a combinator
2745 if ( Expr.relative[ (type = token.type) ] ) {
2746 break;
2747 }
2748 if ( (find = Expr.find[ type ]) ) {
2749 // Search, expanding context for leading sibling combinators
2750 if ( (seed = find(
2751 token.matches[0].replace( runescape, funescape ),
2752 rsibling.test( tokens[0].type ) && context.parentNode || context
2753 )) ) {
2754
2755 // If seed is empty or no tokens remain, we can return early
2756 tokens.splice( i, 1 );
2757 selector = seed.length && toSelector( tokens );
2758 if ( !selector ) {
2759 push.apply( results, seed );
2760 return results;
2761 }
2762
2763 break;
2764 }
2765 }
2766 }
2767 }
2768 }
2769
2770 // Compile and execute a filtering function
2771 // Provide `match` to avoid retokenization if we modified the selector above
2772 compile( selector, match )(
2773 seed,
2774 context,
2775 !documentIsHTML,

Callers 13

SizzleFunction · 0.70
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50
SizzleFunction · 0.50

Calls 2

tokenizeFunction · 0.70
toSelectorFunction · 0.70

Tested by

no test coverage detected