MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / superMatcher

Function superMatcher

Three.js/js/jquery-1.9.1.js:5326–5415  ·  view source on GitHub ↗
( seed, context, xml, results, expandContext )

Source from the content-addressed store, hash-verified

5324 bySet = setMatchers.length > 0,
5325 byElement = elementMatchers.length > 0,
5326 superMatcher = function( seed, context, xml, results, expandContext ) {
5327 var elem, j, matcher,
5328 setMatched = [],
5329 matchedCount = 0,
5330 i = "0",
5331 unmatched = seed && [],
5332 outermost = expandContext != null,
5333 contextBackup = outermostContext,
5334 // We must always have either seed elements or context
5335 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
5336 // Use integer dirruns iff this is the outermost matcher
5337 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
5338
5339 if ( outermost ) {
5340 outermostContext = context !== document && context;
5341 cachedruns = matcherCachedRuns;
5342 }
5343
5344 // Add elements passing elementMatchers directly to results
5345 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
5346 for ( ; (elem = elems[i]) != null; i++ ) {
5347 if ( byElement && elem ) {
5348 j = 0;
5349 while ( (matcher = elementMatchers[j++]) ) {
5350 if ( matcher( elem, context, xml ) ) {
5351 results.push( elem );
5352 break;
5353 }
5354 }
5355 if ( outermost ) {
5356 dirruns = dirrunsUnique;
5357 cachedruns = ++matcherCachedRuns;
5358 }
5359 }
5360
5361 // Track unmatched elements for set filters
5362 if ( bySet ) {
5363 // They will have gone through all possible matchers
5364 if ( (elem = !matcher && elem) ) {
5365 matchedCount--;
5366 }
5367
5368 // Lengthen the array for every element, matched or not
5369 if ( seed ) {
5370 unmatched.push( elem );
5371 }
5372 }
5373 }
5374
5375 // Apply set filters to unmatched elements
5376 matchedCount += i;
5377 if ( bySet && i !== matchedCount ) {
5378 j = 0;
5379 while ( (matcher = setMatchers[j++]) ) {
5380 matcher( unmatched, setMatched, context, xml );
5381 }
5382
5383 if ( seed ) {

Callers

nothing calls this directly

Calls 1

condenseFunction · 0.85

Tested by

no test coverage detected