( elementMatchers, setMatchers )
| 2504 | } |
| 2505 | |
| 2506 | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
| 2507 | var bySet = setMatchers.length > 0, |
| 2508 | byElement = elementMatchers.length > 0, |
| 2509 | superMatcher = function( seed, context, xml, results, outermost ) { |
| 2510 | var elem, j, matcher, |
| 2511 | matchedCount = 0, |
| 2512 | i = "0", |
| 2513 | unmatched = seed && [], |
| 2514 | setMatched = [], |
| 2515 | contextBackup = outermostContext, |
| 2516 | // We must always have either seed elements or outermost context |
| 2517 | elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), |
| 2518 | // Use integer dirruns iff this is the outermost matcher |
| 2519 | dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), |
| 2520 | len = elems.length; |
| 2521 | |
| 2522 | if ( outermost ) { |
| 2523 | outermostContext = context === document || context || outermost; |
| 2524 | } |
| 2525 | |
| 2526 | // Add elements passing elementMatchers directly to results |
| 2527 | // Support: IE<9, Safari |
| 2528 | // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
| 2529 | for ( ; i !== len && (elem = elems[i]) != null; i++ ) { |
| 2530 | if ( byElement && elem ) { |
| 2531 | j = 0; |
| 2532 | if ( !context && elem.ownerDocument !== document ) { |
| 2533 | setDocument( elem ); |
| 2534 | xml = !documentIsHTML; |
| 2535 | } |
| 2536 | while ( (matcher = elementMatchers[j++]) ) { |
| 2537 | if ( matcher( elem, context || document, xml) ) { |
| 2538 | results.push( elem ); |
| 2539 | break; |
| 2540 | } |
| 2541 | } |
| 2542 | if ( outermost ) { |
| 2543 | dirruns = dirrunsUnique; |
| 2544 | } |
| 2545 | } |
| 2546 | |
| 2547 | // Track unmatched elements for set filters |
| 2548 | if ( bySet ) { |
| 2549 | // They will have gone through all possible matchers |
| 2550 | if ( (elem = !matcher && elem) ) { |
| 2551 | matchedCount--; |
| 2552 | } |
| 2553 | |
| 2554 | // Lengthen the array for every element, matched or not |
| 2555 | if ( seed ) { |
| 2556 | unmatched.push( elem ); |
| 2557 | } |
| 2558 | } |
| 2559 | } |
| 2560 | |
| 2561 | // `i` is now the count of elements visited above, and adding it to `matchedCount` |
| 2562 | // makes the latter nonnegative. |
| 2563 | matchedCount += i; |
no test coverage detected
searching dependent graphs…