MCPcopy Create free account
hub / github.com/frank-lam/fullstack-tutorial / superMatcher

Function superMatcher

notes/docsify/unpkg/gotop/jquery-2.1.0.js:2298–2387  ·  view source on GitHub ↗
( seed, context, xml, results, outermost )

Source from the content-addressed store, hash-verified

2296 var bySet = setMatchers.length > 0,
2297 byElement = elementMatchers.length > 0,
2298 superMatcher = function( seed, context, xml, results, outermost ) {
2299 var elem, j, matcher,
2300 matchedCount = 0,
2301 i = "0",
2302 unmatched = seed && [],
2303 setMatched = [],
2304 contextBackup = outermostContext,
2305 // We must always have either seed elements or outermost context
2306 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2307 // Use integer dirruns iff this is the outermost matcher
2308 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2309 len = elems.length;
2310
2311 if ( outermost ) {
2312 outermostContext = context !== document && context;
2313 }
2314
2315 // Add elements passing elementMatchers directly to results
2316 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2317 // Support: IE<9, Safari
2318 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2319 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2320 if ( byElement && elem ) {
2321 j = 0;
2322 while ( (matcher = elementMatchers[j++]) ) {
2323 if ( matcher( elem, context, xml ) ) {
2324 results.push( elem );
2325 break;
2326 }
2327 }
2328 if ( outermost ) {
2329 dirruns = dirrunsUnique;
2330 }
2331 }
2332
2333 // Track unmatched elements for set filters
2334 if ( bySet ) {
2335 // They will have gone through all possible matchers
2336 if ( (elem = !matcher && elem) ) {
2337 matchedCount--;
2338 }
2339
2340 // Lengthen the array for every element, matched or not
2341 if ( seed ) {
2342 unmatched.push( elem );
2343 }
2344 }
2345 }
2346
2347 // Apply set filters to unmatched elements
2348 matchedCount += i;
2349 if ( bySet && i !== matchedCount ) {
2350 j = 0;
2351 while ( (matcher = setMatchers[j++]) ) {
2352 matcher( unmatched, setMatched, context, xml );
2353 }
2354
2355 if ( seed ) {

Callers

nothing calls this directly

Calls 1

condenseFunction · 0.85

Tested by

no test coverage detected