( tokens )
| 2238 | } |
| 2239 | |
| 2240 | function matcherFromTokens( tokens ) { |
| 2241 | var checkContext, matcher, j, |
| 2242 | len = tokens.length, |
| 2243 | leadingRelative = Expr.relative[ tokens[0].type ], |
| 2244 | implicitRelative = leadingRelative || Expr.relative[" "], |
| 2245 | i = leadingRelative ? 1 : 0, |
| 2246 | |
| 2247 | // The foundational matcher ensures that elements are reachable from top-level context(s) |
| 2248 | matchContext = addCombinator( function( elem ) { |
| 2249 | return elem === checkContext; |
| 2250 | }, implicitRelative, true ), |
| 2251 | matchAnyContext = addCombinator( function( elem ) { |
| 2252 | return indexOf.call( checkContext, elem ) > -1; |
| 2253 | }, implicitRelative, true ), |
| 2254 | matchers = [ function( elem, context, xml ) { |
| 2255 | return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
| 2256 | (checkContext = context).nodeType ? |
| 2257 | matchContext( elem, context, xml ) : |
| 2258 | matchAnyContext( elem, context, xml ) ); |
| 2259 | } ]; |
| 2260 | |
| 2261 | for ( ; i < len; i++ ) { |
| 2262 | if ( (matcher = Expr.relative[ tokens[i].type ]) ) { |
| 2263 | matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; |
| 2264 | } else { |
| 2265 | matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); |
| 2266 | |
| 2267 | // Return special upon seeing a positional matcher |
| 2268 | if ( matcher[ expando ] ) { |
| 2269 | // Find the next relative operator (if any) for proper handling |
| 2270 | j = ++i; |
| 2271 | for ( ; j < len; j++ ) { |
| 2272 | if ( Expr.relative[ tokens[j].type ] ) { |
| 2273 | break; |
| 2274 | } |
| 2275 | } |
| 2276 | return setMatcher( |
| 2277 | i > 1 && elementMatcher( matchers ), |
| 2278 | i > 1 && toSelector( |
| 2279 | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
| 2280 | tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) |
| 2281 | ).replace( rtrim, "$1" ), |
| 2282 | matcher, |
| 2283 | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
| 2284 | j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), |
| 2285 | j < len && toSelector( tokens ) |
| 2286 | ); |
| 2287 | } |
| 2288 | matchers.push( matcher ); |
| 2289 | } |
| 2290 | } |
| 2291 | |
| 2292 | return elementMatcher( matchers ); |
| 2293 | } |
| 2294 | |
| 2295 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
| 2296 | var bySet = setMatchers.length > 0, |
no test coverage detected
searching dependent graphs…