( preFilter, selector, matcher, postFilter, postFinder, postSelector )
| 4831 | } |
| 4832 | |
| 4833 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
| 4834 | if ( postFilter && !postFilter[ expando ] ) { |
| 4835 | postFilter = setMatcher( postFilter ); |
| 4836 | } |
| 4837 | if ( postFinder && !postFinder[ expando ] ) { |
| 4838 | postFinder = setMatcher( postFinder, postSelector ); |
| 4839 | } |
| 4840 | return markFunction(function( seed, results, context, xml ) { |
| 4841 | var temp, i, elem, |
| 4842 | preMap = [], |
| 4843 | postMap = [], |
| 4844 | preexisting = results.length, |
| 4845 | |
| 4846 | // Get initial elements from seed or context |
| 4847 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
| 4848 | |
| 4849 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
| 4850 | matcherIn = preFilter && ( seed || !selector ) ? |
| 4851 | condense( elems, preMap, preFilter, context, xml ) : |
| 4852 | elems, |
| 4853 | |
| 4854 | matcherOut = matcher ? |
| 4855 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
| 4856 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
| 4857 | |
| 4858 | // ...intermediate processing is necessary |
| 4859 | [] : |
| 4860 | |
| 4861 | // ...otherwise use results directly |
| 4862 | results : |
| 4863 | matcherIn; |
| 4864 | |
| 4865 | // Find primary matches |
| 4866 | if ( matcher ) { |
| 4867 | matcher( matcherIn, matcherOut, context, xml ); |
| 4868 | } |
| 4869 | |
| 4870 | // Apply postFilter |
| 4871 | if ( postFilter ) { |
| 4872 | temp = condense( matcherOut, postMap ); |
| 4873 | postFilter( temp, [], context, xml ); |
| 4874 | |
| 4875 | // Un-match failing elements by moving them back to matcherIn |
| 4876 | i = temp.length; |
| 4877 | while ( i-- ) { |
| 4878 | if ( (elem = temp[i]) ) { |
| 4879 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
| 4880 | } |
| 4881 | } |
| 4882 | } |
| 4883 | |
| 4884 | if ( seed ) { |
| 4885 | if ( postFinder || preFilter ) { |
| 4886 | if ( postFinder ) { |
| 4887 | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
| 4888 | temp = []; |
| 4889 | i = matcherOut.length; |
| 4890 | while ( i-- ) { |
no test coverage detected