MCPcopy Create free account
hub / github.com/nwutils/nw-sample-apps / superMatcher

Function superMatcher

camera/jquery.js:2314–2403  ·  view source on GitHub ↗
( seed, context, xml, results, outermost )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

condenseFunction · 0.85

Tested by

no test coverage detected