MCPcopy
hub / github.com/mongodb/node-mongodb-native / select

Function select

docs/3.5/js/jquery.js:2845–2907  ·  docs/3.5/js/jquery.js::select
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

2843}
2844
2845function select( selector, context, results, seed ) {
2846 var i, tokens, token, type, find,
2847 match = tokenize( selector );
2848
2849 if ( !seed ) {
2850 class="cm">// Try to minimize operations if there is only one group
2851 if ( match.length === 1 ) {
2852
2853 class="cm">// Take a shortcut and set the context if the root selector is an ID
2854 tokens = match[0] = match[0].slice( 0 );
2855 if ( tokens.length > 2 && (token = tokens[0]).type === class="st">"ID" &&
2856 support.getById && context.nodeType === 9 && documentIsHTML &&
2857 Expr.relative[ tokens[1].type ] ) {
2858
2859 context = ( Expr.find[class="st">"ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2860 if ( !context ) {
2861 return results;
2862 }
2863 selector = selector.slice( tokens.shift().value.length );
2864 }
2865
2866 class="cm">// Fetch a seed set for right-to-left matching
2867 i = matchExpr[class="st">"needsContext"].test( selector ) ? 0 : tokens.length;
2868 while ( i-- ) {
2869 token = tokens[i];
2870
2871 class="cm">// Abort if we hit a combinator
2872 if ( Expr.relative[ (type = token.type) ] ) {
2873 break;
2874 }
2875 if ( (find = Expr.find[ type ]) ) {
2876 class="cm">// Search, expanding context for leading sibling combinators
2877 if ( (seed = find(
2878 token.matches[0].replace( runescape, funescape ),
2879 rsibling.test( tokens[0].type ) && context.parentNode || context
2880 )) ) {
2881
2882 class="cm">// If seed is empty or no tokens remain, we can return early
2883 tokens.splice( i, 1 );
2884 selector = seed.length && toSelector( tokens );
2885 if ( !selector ) {
2886 push.apply( results, seed );
2887 return results;
2888 }
2889
2890 break;
2891 }
2892 }
2893 }
2894 }
2895 }
2896
2897 class="cm">// Compile and execute a filtering function
2898 class="cm">// Provide `match` to avoid retokenization if we modified the selector above
2899 compile( selector, match )(
2900 seed,
2901 context,
2902 !documentIsHTML,

Callers 1

SizzleFunction · 0.70

Calls 6

findFunction · 0.85
testMethod · 0.80
applyMethod · 0.80
tokenizeFunction · 0.70
toSelectorFunction · 0.70
shiftMethod · 0.45

Tested by

no test coverage detected