MCPcopy Create free account
hub / github.com/OpenIntroStat/ims / addCombinator

Function addCombinator

libs/jquery-3.5.1/jquery-2.2.4.js:2140–2196  ·  view source on GitHub ↗
( matcher, combinator, base )

Source from the content-addressed store, hash-verified

2138}
2139
2140function addCombinator( matcher, combinator, base ) {
2141 var dir = combinator.dir,
2142 checkNonElements = base && dir === "parentNode",
2143 doneName = done++;
2144
2145 return combinator.first ?
2146 // Check against closest ancestor/preceding element
2147 function( elem, context, xml ) {
2148 while ( (elem = elem[ dir ]) ) {
2149 if ( elem.nodeType === 1 || checkNonElements ) {
2150 return matcher( elem, context, xml );
2151 }
2152 }
2153 } :
2154
2155 // Check against all ancestor/preceding elements
2156 function( elem, context, xml ) {
2157 var oldCache, uniqueCache, outerCache,
2158 newCache = [ dirruns, doneName ];
2159
2160 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2161 if ( xml ) {
2162 while ( (elem = elem[ dir ]) ) {
2163 if ( elem.nodeType === 1 || checkNonElements ) {
2164 if ( matcher( elem, context, xml ) ) {
2165 return true;
2166 }
2167 }
2168 }
2169 } else {
2170 while ( (elem = elem[ dir ]) ) {
2171 if ( elem.nodeType === 1 || checkNonElements ) {
2172 outerCache = elem[ expando ] || (elem[ expando ] = {});
2173
2174 // Support: IE <9 only
2175 // Defend against cloned attroperties (jQuery gh-1709)
2176 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2177
2178 if ( (oldCache = uniqueCache[ dir ]) &&
2179 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2180
2181 // Assign to newCache so results back-propagate to previous elements
2182 return (newCache[ 2 ] = oldCache[ 2 ]);
2183 } else {
2184 // Reuse newcache so results back-propagate to previous elements
2185 uniqueCache[ dir ] = newCache;
2186
2187 // A match means we're done; a fail means we have to keep checking
2188 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2189 return true;
2190 }
2191 }
2192 }
2193 }
2194 }
2195 };
2196}
2197

Callers 1

matcherFromTokensFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected