( preFilter, selector, matcher, postFilter, postFinder, postSelector )
| 2235 | } |
| 2236 | |
| 2237 | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
| 2238 | if ( postFilter && !postFilter[ expando ] ) { |
| 2239 | postFilter = setMatcher( postFilter ); |
| 2240 | } |
| 2241 | if ( postFinder && !postFinder[ expando ] ) { |
| 2242 | postFinder = setMatcher( postFinder, postSelector ); |
| 2243 | } |
| 2244 | return markFunction(function( seed, results, context, xml ) { |
| 2245 | var temp, i, elem, |
| 2246 | preMap = [], |
| 2247 | postMap = [], |
| 2248 | preexisting = results.length, |
| 2249 | |
| 2250 | // Get initial elements from seed or context |
| 2251 | elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
| 2252 | |
| 2253 | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
| 2254 | matcherIn = preFilter && ( seed || !selector ) ? |
| 2255 | condense( elems, preMap, preFilter, context, xml ) : |
| 2256 | elems, |
| 2257 | |
| 2258 | matcherOut = matcher ? |
| 2259 | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
| 2260 | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
| 2261 | |
| 2262 | // ...intermediate processing is necessary |
| 2263 | [] : |
| 2264 | |
| 2265 | // ...otherwise use results directly |
| 2266 | results : |
| 2267 | matcherIn; |
| 2268 | |
| 2269 | // Find primary matches |
| 2270 | if ( matcher ) { |
| 2271 | matcher( matcherIn, matcherOut, context, xml ); |
| 2272 | } |
| 2273 | |
| 2274 | // Apply postFilter |
| 2275 | if ( postFilter ) { |
| 2276 | temp = condense( matcherOut, postMap ); |
| 2277 | postFilter( temp, [], context, xml ); |
| 2278 | |
| 2279 | // Un-match failing elements by moving them back to matcherIn |
| 2280 | i = temp.length; |
| 2281 | while ( i-- ) { |
| 2282 | if ( (elem = temp[i]) ) { |
| 2283 | matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
| 2284 | } |
| 2285 | } |
| 2286 | } |
| 2287 | |
| 2288 | if ( seed ) { |
| 2289 | if ( postFinder || preFilter ) { |
| 2290 | if ( postFinder ) { |
| 2291 | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
| 2292 | temp = []; |
| 2293 | i = matcherOut.length; |
| 2294 | while ( i-- ) { |
no test coverage detected