MCPcopy Index your code
hub / github.com/components/jquery / addCombinator

Function addCombinator

jquery.js:1944–2004  ·  view source on GitHub ↗
( matcher, combinator, base )

Source from the content-addressed store, hash-verified

1942jQuery.expr.setFilters = new setFilters();
1943
1944function addCombinator( matcher, combinator, base ) {
1945 var dir = combinator.dir,
1946 skip = combinator.next,
1947 key = skip || dir,
1948 checkNonElements = base && key === "parentNode",
1949 doneName = done++;
1950
1951 return combinator.first ?
1952
1953 // Check against closest ancestor/preceding element
1954 function( elem, context, xml ) {
1955 while ( ( elem = elem[ dir ] ) ) {
1956 if ( elem.nodeType === 1 || checkNonElements ) {
1957 return matcher( elem, context, xml );
1958 }
1959 }
1960 return false;
1961 } :
1962
1963 // Check against all ancestor/preceding elements
1964 function( elem, context, xml ) {
1965 var oldCache, outerCache,
1966 newCache = [ dirruns, doneName ];
1967
1968 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
1969 if ( xml ) {
1970 while ( ( elem = elem[ dir ] ) ) {
1971 if ( elem.nodeType === 1 || checkNonElements ) {
1972 if ( matcher( elem, context, xml ) ) {
1973 return true;
1974 }
1975 }
1976 }
1977 } else {
1978 while ( ( elem = elem[ dir ] ) ) {
1979 if ( elem.nodeType === 1 || checkNonElements ) {
1980 outerCache = elem[ jQuery.expando ] || ( elem[ jQuery.expando ] = {} );
1981
1982 if ( skip && nodeName( elem, skip ) ) {
1983 elem = elem[ dir ] || elem;
1984 } else if ( ( oldCache = outerCache[ key ] ) &&
1985 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
1986
1987 // Assign to newCache so results back-propagate to previous elements
1988 return ( newCache[ 2 ] = oldCache[ 2 ] );
1989 } else {
1990
1991 // Reuse newcache so results back-propagate to previous elements
1992 outerCache[ key ] = newCache;
1993
1994 // A match means we're done; a fail means we have to keep checking
1995 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
1996 return true;
1997 }
1998 }
1999 }
2000 }
2001 }

Callers 2

jquery.jsFile · 0.70
matcherFromTokensFunction · 0.70

Calls 1

nodeNameFunction · 0.70

Tested by

no test coverage detected