MCPcopy Index your code
hub / github.com/sql-js/sql.js / select

Function select

documentation/javascript/application.js:5852–5932  ·  view source on GitHub ↗
( selector, context, results, seed, xml )

Source from the content-addressed store, hash-verified

5850}
5851
5852function select( selector, context, results, seed, xml ) {
5853 // Remove excessive whitespace
5854 selector = selector.replace( rtrim, "$1" );
5855 var elements, matcher, cached, elem,
5856 i, tokens, token, lastToken, findContext, type,
5857 match = tokenize( selector, context, xml ),
5858 contextNodeType = context.nodeType;
5859
5860 // POS handling
5861 if ( matchExpr["POS"].test(selector) ) {
5862 return handlePOS( match, context, results, seed );
5863 }
5864
5865 if ( seed ) {
5866 elements = slice.call( seed, 0 );
5867
5868 // To maintain document order, only narrow the
5869 // set if there is one group
5870 } else if ( match.length === 1 ) {
5871
5872 // Take a shortcut and set the context if the root selector is an ID
5873 if ( (tokens = slice.call( match[0], 0 )).length > 2 &&
5874 (token = tokens[0]).part === "ID" &&
5875 contextNodeType === 9 && !xml &&
5876 Expr.relative[ tokens[1].part ] ) {
5877
5878 context = Expr.find["ID"]( token.captures[0].replace( rbackslash, "" ), context, xml )[0];
5879 if ( !context ) {
5880 return results;
5881 }
5882
5883 selector = selector.slice( tokens.shift().string.length );
5884 }
5885
5886 findContext = ( (match = rsibling.exec( tokens[0].string )) && !match.index && context.parentNode ) || context;
5887
5888 // Reduce the set if possible
5889 lastToken = "";
5890 for ( i = tokens.length - 1; i >= 0; i-- ) {
5891 token = tokens[i];
5892 type = token.part;
5893 lastToken = token.string + lastToken;
5894 if ( Expr.relative[ type ] ) {
5895 break;
5896 }
5897 if ( Expr.order.test(type) ) {
5898 elements = Expr.find[ type ]( token.captures[0].replace( rbackslash, "" ), findContext, xml );
5899 if ( elements == null ) {
5900 continue;
5901 } else {
5902 selector = selector.slice( 0, selector.length - lastToken.length ) +
5903 lastToken.replace( matchExpr[ type ], "" );
5904
5905 if ( !selector ) {
5906 push.apply( results, slice.call(elements, 0) );
5907 }
5908
5909 break;

Callers 1

SizzleFunction · 0.85

Calls 2

tokenizeFunction · 0.85
handlePOSFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…