MCPcopy Index your code
hub / github.com/jquery/jquery / superMatcher

Function superMatcher

dist-module/jquery.module.js:2206–2318  ·  view source on GitHub ↗
( seed, context, xml, results, outermost )

Source from the content-addressed store, hash-verified

2204 var bySet = setMatchers.length > 0,
2205 byElement = elementMatchers.length > 0,
2206 superMatcher = function( seed, context, xml, results, outermost ) {
2207 var elem, j, matcher,
2208 matchedCount = 0,
2209 i = "0",
2210 unmatched = seed && [],
2211 setMatched = [],
2212 contextBackup = outermostContext,
2213
2214 // We must always have either seed elements or outermost context
2215 elems = seed || byElement && jQuery.expr.find.TAG( "*", outermost ),
2216
2217 // Use integer dirruns iff this is the outermost matcher
2218 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 );
2219
2220 if ( outermost ) {
2221
2222 // Support: IE 11+
2223 // IE sometimes throws a "Permission denied" error when strict-comparing
2224 // two documents; shallow comparisons work.
2225 // eslint-disable-next-line eqeqeq
2226 outermostContext = context == document || context || outermost;
2227 }
2228
2229 // Add elements passing elementMatchers directly to results
2230 for ( ; ( elem = elems[ i ] ) != null; i++ ) {
2231 if ( byElement && elem ) {
2232 j = 0;
2233
2234 // Support: IE 11+
2235 // IE sometimes throws a "Permission denied" error when strict-comparing
2236 // two documents; shallow comparisons work.
2237 // eslint-disable-next-line eqeqeq
2238 if ( !context && elem.ownerDocument != document ) {
2239 setDocument( elem );
2240 xml = !documentIsHTML;
2241 }
2242 while ( ( matcher = elementMatchers[ j++ ] ) ) {
2243 if ( matcher( elem, context || document, xml ) ) {
2244 push.call( results, elem );
2245 break;
2246 }
2247 }
2248 if ( outermost ) {
2249 dirruns = dirrunsUnique;
2250 }
2251 }
2252
2253 // Track unmatched elements for set filters
2254 if ( bySet ) {
2255
2256 // They will have gone through all possible matchers
2257 if ( ( elem = !matcher && elem ) ) {
2258 matchedCount--;
2259 }
2260
2261 // Lengthen the array for every element, matched or not
2262 if ( seed ) {
2263 unmatched.push( elem );

Callers

nothing calls this directly

Calls 2

setDocumentFunction · 0.70
condenseFunction · 0.70

Tested by

no test coverage detected