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

Function matcherFromGroupMatchers

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

Source from the content-addressed store, hash-verified

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

Callers 1

jquery-2.1.1.jsFile · 0.70

Calls 1

markFunctionFunction · 0.70

Tested by

no test coverage detected