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