( tokens )
| 2290 | } |
| 2291 | |
| 2292 | function matcherFromTokens( tokens ) { |
| 2293 | var checkContext, matcher, j, |
| 2294 | len = tokens.length, |
| 2295 | leadingRelative = Expr.relative[ tokens[0].type ], |
| 2296 | implicitRelative = leadingRelative || Expr.relative[" "], |
| 2297 | i = leadingRelative ? 1 : 0, |
| 2298 | |
| 2299 | // The foundational matcher ensures that elements are reachable from top-level context(s) |
| 2300 | matchContext = addCombinator( function( elem ) { |
| 2301 | return elem === checkContext; |
| 2302 | }, implicitRelative, true ), |
| 2303 | matchAnyContext = addCombinator( function( elem ) { |
| 2304 | return indexOf.call( checkContext, elem ) > -1; |
| 2305 | }, implicitRelative, true ), |
| 2306 | matchers = [ function( elem, context, xml ) { |
| 2307 | return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
| 2308 | (checkContext = context).nodeType ? |
| 2309 | matchContext( elem, context, xml ) : |
| 2310 | matchAnyContext( elem, context, xml ) ); |
| 2311 | } ]; |
| 2312 | |
| 2313 | for ( ; i < len; i++ ) { |
| 2314 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) { |
| 2315 | matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; |
| 2316 | } else { |
| 2317 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); |
| 2318 | |
| 2319 | // Return special upon seeing a positional matcher |
| 2320 | if ( matcher[ expando ] ) { |
| 2321 | // Find the next relative operator (if any) for proper handling |
| 2322 | j = ++i; |
| 2323 | for ( ; j < len; j++ ) { |
| 2324 | if ( Expr.relative[ tokens[j].type ] ) { |
| 2325 | break; |
| 2326 | } |
| 2327 | } |
| 2328 | return setMatcher( |
| 2329 | i > 1 && elementMatcher( matchers ), |
| 2330 | i > 1 && toSelector( |
| 2331 | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
| 2332 | tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) |
| 2333 | ).replace( rtrim, "$1" ), |
| 2334 | matcher, |
| 2335 | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
| 2336 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), |
| 2337 | j < len && toSelector( tokens ) |
| 2338 | ); |
| 2339 | } |
| 2340 | matchers.push( matcher ); |
| 2341 | } |
| 2342 | } |
| 2343 | |
| 2344 | return elementMatcher( matchers ); |
| 2345 | } |
| 2346 | |
| 2347 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
| 2348 | var bySet = setMatchers.length > 0, |
no test coverage detected