MCPcopy Create free account
hub / github.com/JsAaron/jQuery / matcherFromGroupMatchers

Function matcherFromGroupMatchers

2.1.1/test/jquery-1.11.1.js:2347–2444  ·  view source on GitHub ↗
( elementMatchers, setMatchers )

Source from the content-addressed store, hash-verified

2345}
2346
2347function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2348 var bySet = setMatchers.length > 0,
2349 byElement = elementMatchers.length > 0,
2350 superMatcher = function( seed, context, xml, results, outermost ) {
2351 var elem, j, matcher,
2352 matchedCount = 0,
2353 i = "0",
2354 unmatched = seed && [],
2355 setMatched = [],
2356 contextBackup = outermostContext,
2357 // We must always have either seed elements or outermost context
2358 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2359 // Use integer dirruns iff this is the outermost matcher
2360 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2361 len = elems.length;
2362
2363 if ( outermost ) {
2364 outermostContext = context !== document && context;
2365 }
2366
2367 // Add elements passing elementMatchers directly to results
2368 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2369 // Support: IE<9, Safari
2370 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2371 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2372 if ( byElement && elem ) {
2373 j = 0;
2374 while ( (matcher = elementMatchers[j++]) ) {
2375 if ( matcher( elem, context, xml ) ) {
2376 results.push( elem );
2377 break;
2378 }
2379 }
2380 if ( outermost ) {
2381 dirruns = dirrunsUnique;
2382 }
2383 }
2384
2385 // Track unmatched elements for set filters
2386 if ( bySet ) {
2387 // They will have gone through all possible matchers
2388 if ( (elem = !matcher && elem) ) {
2389 matchedCount--;
2390 }
2391
2392 // Lengthen the array for every element, matched or not
2393 if ( seed ) {
2394 unmatched.push( elem );
2395 }
2396 }
2397 }
2398
2399 // Apply set filters to unmatched elements
2400 matchedCount += i;
2401 if ( bySet && i !== matchedCount ) {
2402 j = 0;
2403 while ( (matcher = setMatchers[j++]) ) {
2404 matcher( unmatched, setMatched, context, xml );

Callers 1

jquery-1.11.1.jsFile · 0.70

Calls 1

markFunctionFunction · 0.70

Tested by

no test coverage detected