MCPcopy Create free account
hub / github.com/TruthHun/BookStack / superMatcher

Function superMatcher

static/jquery/1.12.4/jquery.js:2430–2531  ·  view source on GitHub ↗
( seed, context, xml, results, outermost )

Source from the content-addressed store, hash-verified

2428 var bySet = setMatchers.length > 0,
2429 byElement = elementMatchers.length > 0,
2430 superMatcher = function( seed, context, xml, results, outermost ) {
2431 var elem, j, matcher,
2432 matchedCount = 0,
2433 i = "0",
2434 unmatched = seed && [],
2435 setMatched = [],
2436 contextBackup = outermostContext,
2437 // We must always have either seed elements or outermost context
2438 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2439 // Use integer dirruns iff this is the outermost matcher
2440 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2441 len = elems.length;
2442
2443 if ( outermost ) {
2444 outermostContext = context === document || context || outermost;
2445 }
2446
2447 // Add elements passing elementMatchers directly to results
2448 // Support: IE<9, Safari
2449 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2450 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2451 if ( byElement && elem ) {
2452 j = 0;
2453 if ( !context && elem.ownerDocument !== document ) {
2454 setDocument( elem );
2455 xml = !documentIsHTML;
2456 }
2457 while ( (matcher = elementMatchers[j++]) ) {
2458 if ( matcher( elem, context || document, xml) ) {
2459 results.push( elem );
2460 break;
2461 }
2462 }
2463 if ( outermost ) {
2464 dirruns = dirrunsUnique;
2465 }
2466 }
2467
2468 // Track unmatched elements for set filters
2469 if ( bySet ) {
2470 // They will have gone through all possible matchers
2471 if ( (elem = !matcher && elem) ) {
2472 matchedCount--;
2473 }
2474
2475 // Lengthen the array for every element, matched or not
2476 if ( seed ) {
2477 unmatched.push( elem );
2478 }
2479 }
2480 }
2481
2482 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2483 // makes the latter nonnegative.
2484 matchedCount += i;
2485
2486 // Apply set filters to unmatched elements
2487 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`

Callers

nothing calls this directly

Calls 1

condenseFunction · 0.70

Tested by

no test coverage detected