MCPcopy Index your code
hub / github.com/JsAaron/jQuery / superMatcher

Function superMatcher

2.0.3/2.0.3.js:2587–2676  ·  view source on GitHub ↗
( seed, context, xml, results, expandContext )

Source from the content-addressed store, hash-verified

2585 bySet = setMatchers.length > 0,
2586 byElement = elementMatchers.length > 0,
2587 superMatcher = function( seed, context, xml, results, expandContext ) {
2588 var elem, j, matcher,
2589 setMatched = [],
2590 matchedCount = 0,
2591 i = "0",
2592 unmatched = seed && [],
2593 outermost = expandContext != null,
2594 contextBackup = outermostContext,
2595 // We must always have either seed elements or context
2596 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
2597 // Use integer dirruns iff this is the outermost matcher
2598 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
2599
2600 if ( outermost ) {
2601 outermostContext = context !== document && context;
2602 cachedruns = matcherCachedRuns;
2603 }
2604
2605 // Add elements passing elementMatchers directly to results
2606 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2607 for ( ; (elem = elems[i]) != null; i++ ) {
2608 if ( byElement && elem ) {
2609 j = 0;
2610 while ( (matcher = elementMatchers[j++]) ) {
2611 if ( matcher( elem, context, xml ) ) {
2612 results.push( elem );
2613 break;
2614 }
2615 }
2616 if ( outermost ) {
2617 dirruns = dirrunsUnique;
2618 cachedruns = ++matcherCachedRuns;
2619 }
2620 }
2621
2622 // Track unmatched elements for set filters
2623 if ( bySet ) {
2624 // They will have gone through all possible matchers
2625 if ( (elem = !matcher && elem) ) {
2626 matchedCount--;
2627 }
2628
2629 // Lengthen the array for every element, matched or not
2630 if ( seed ) {
2631 unmatched.push( elem );
2632 }
2633 }
2634 }
2635
2636 // Apply set filters to unmatched elements
2637 matchedCount += i;
2638 if ( bySet && i !== matchedCount ) {
2639 j = 0;
2640 while ( (matcher = setMatchers[j++]) ) {
2641 matcher( unmatched, setMatched, context, xml );
2642 }
2643
2644 if ( seed ) {

Callers

nothing calls this directly

Calls 1

condenseFunction · 0.70

Tested by

no test coverage detected