( preFilter, selector, matcher, postFilter, postFinder, postSelector )
| 2180 | } |
| 2181 | |
| 2182 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
| 2183 | if ( postFilter && !postFilter[ expando ] ) { |
| 2184 | postFilter = setMatcher( postFilter ); |
| 2185 | } |
| 2186 | if ( postFinder && !postFinder[ expando ] ) { |
| 2187 | postFinder = setMatcher( postFinder, postSelector ); |
| 2188 | } |
| 2189 | return markFunction(function( seed, results, context, xml ) { |
| 2190 | var temp, i, elem, |
| 2191 | preMap = [], |
| 2192 | postMap = [], |
| 2193 | preexisting = results.length, |
| 2194 | |
| 2195 | // Get initial elements from seed or context |
| 2196 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
| 2197 | |
| 2198 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
| 2199 | matcherIn = preFilter && ( seed || !selector ) ? |
| 2200 | condense( elems, preMap, preFilter, context, xml ) : |
| 2201 | elems, |
| 2202 | |
| 2203 | matcherOut = matcher ? |
| 2204 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
| 2205 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
| 2206 | |
| 2207 | // ...intermediate processing is necessary |
| 2208 | [] : |
| 2209 | |
| 2210 | // ...otherwise use results directly |
| 2211 | results : |
| 2212 | matcherIn; |
| 2213 | |
| 2214 | // Find primary matches |
| 2215 | if ( matcher ) { |
| 2216 | matcher( matcherIn, matcherOut, context, xml ); |
| 2217 | } |
| 2218 | |
| 2219 | // Apply postFilter |
| 2220 | if ( postFilter ) { |
| 2221 | temp = condense( matcherOut, postMap ); |
| 2222 | postFilter( temp, [], context, xml ); |
| 2223 | |
| 2224 | // Un-match failing elements by moving them back to matcherIn |
| 2225 | i = temp.length; |
| 2226 | while ( i-- ) { |
| 2227 | if ( (elem = temp[i]) ) { |
| 2228 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
| 2229 | } |
| 2230 | } |
| 2231 | } |
| 2232 | |
| 2233 | if ( seed ) { |
| 2234 | if ( postFinder || preFilter ) { |
| 2235 | if ( postFinder ) { |
| 2236 | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
| 2237 | temp = []; |
| 2238 | i = matcherOut.length; |
| 2239 | while ( i-- ) { |
no test coverage detected