( preFilter, selector, matcher, postFilter, postFinder, postSelector )
| 2506 | } |
| 2507 | |
| 2508 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
| 2509 | if ( postFilter && !postFilter[ expando ] ) { |
| 2510 | postFilter = setMatcher( postFilter ); |
| 2511 | } |
| 2512 | if ( postFinder && !postFinder[ expando ] ) { |
| 2513 | postFinder = setMatcher( postFinder, postSelector ); |
| 2514 | } |
| 2515 | return markFunction( function( seed, results, context, xml ) { |
| 2516 | var temp, i, elem, |
| 2517 | preMap = [], |
| 2518 | postMap = [], |
| 2519 | preexisting = results.length, |
| 2520 | |
| 2521 | // Get initial elements from seed or context |
| 2522 | elems = seed || multipleContexts( |
| 2523 | selector || "*", |
| 2524 | context.nodeType ? [ context ] : context, |
| 2525 | [] |
| 2526 | ), |
| 2527 | |
| 2528 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
| 2529 | matcherIn = preFilter && ( seed || !selector ) ? |
| 2530 | condense( elems, preMap, preFilter, context, xml ) : |
| 2531 | elems, |
| 2532 | |
| 2533 | matcherOut = matcher ? |
| 2534 | |
| 2535 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
| 2536 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
| 2537 | |
| 2538 | // ...intermediate processing is necessary |
| 2539 | [] : |
| 2540 | |
| 2541 | // ...otherwise use results directly |
| 2542 | results : |
| 2543 | matcherIn; |
| 2544 | |
| 2545 | // Find primary matches |
| 2546 | if ( matcher ) { |
| 2547 | matcher( matcherIn, matcherOut, context, xml ); |
| 2548 | } |
| 2549 | |
| 2550 | // Apply postFilter |
| 2551 | if ( postFilter ) { |
| 2552 | temp = condense( matcherOut, postMap ); |
| 2553 | postFilter( temp, [], context, xml ); |
| 2554 | |
| 2555 | // Un-match failing elements by moving them back to matcherIn |
| 2556 | i = temp.length; |
| 2557 | while ( i-- ) { |
| 2558 | if ( ( elem = temp[ i ] ) ) { |
| 2559 | matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); |
| 2560 | } |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | if ( seed ) { |
| 2565 | if ( postFinder || preFilter ) { |
no test coverage detected