( elementMatchers, setMatchers )
| 2331 | } |
| 2332 | |
| 2333 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
| 2334 | var bySet = setMatchers.length > 0, |
| 2335 | byElement = elementMatchers.length > 0, |
| 2336 | superMatcher = function( seed, context, xml, results, outermost ) { |
| 2337 | var elem, j, matcher, |
| 2338 | matchedCount = 0, |
| 2339 | i = "0", |
| 2340 | unmatched = seed && [], |
| 2341 | setMatched = [], |
| 2342 | contextBackup = outermostContext, |
| 2343 | // We must always have either seed elements or outermost context |
| 2344 | elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), |
| 2345 | // Use integer dirruns iff this is the outermost matcher |
| 2346 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), |
| 2347 | len = elems.length; |
| 2348 | |
| 2349 | if ( outermost ) { |
| 2350 | outermostContext = context !== document && context; |
| 2351 | } |
| 2352 | |
| 2353 | // Add elements passing elementMatchers directly to results |
| 2354 | // Keep `i` a string if there are no elements so `matchedCount` will be "00" below |
| 2355 | // Support: IE<9, Safari |
| 2356 | // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
| 2357 | for ( ; i !== len && (elem = elems[i]) != null; i++ ) { |
| 2358 | if ( byElement && elem ) { |
| 2359 | j = 0; |
| 2360 | while ( (matcher = elementMatchers[j++]) ) { |
| 2361 | if ( matcher( elem, context, xml ) ) { |
| 2362 | results.push( elem ); |
| 2363 | break; |
| 2364 | } |
| 2365 | } |
| 2366 | if ( outermost ) { |
| 2367 | dirruns = dirrunsUnique; |
| 2368 | } |
| 2369 | } |
| 2370 | |
| 2371 | // Track unmatched elements for set filters |
| 2372 | if ( bySet ) { |
| 2373 | // They will have gone through all possible matchers |
| 2374 | if ( (elem = !matcher && elem) ) { |
| 2375 | matchedCount--; |
| 2376 | } |
| 2377 | |
| 2378 | // Lengthen the array for every element, matched or not |
| 2379 | if ( seed ) { |
| 2380 | unmatched.push( elem ); |
| 2381 | } |
| 2382 | } |
| 2383 | } |
| 2384 | |
| 2385 | // Apply set filters to unmatched elements |
| 2386 | matchedCount += i; |
| 2387 | if ( bySet && i !== matchedCount ) { |
| 2388 | j = 0; |
| 2389 | while ( (matcher = setMatchers[j++]) ) { |
| 2390 | matcher( unmatched, setMatched, context, xml ); |
no test coverage detected