( matcher, combinator, base )
| 850 | jQuery.expr.setFilters = new setFilters(); |
| 851 | |
| 852 | function addCombinator( matcher, combinator, base ) { |
| 853 | var dir = combinator.dir, |
| 854 | skip = combinator.next, |
| 855 | key = skip || dir, |
| 856 | checkNonElements = base && key === "parentNode", |
| 857 | doneName = done++; |
| 858 | |
| 859 | return combinator.first ? |
| 860 | |
| 861 | // Check against closest ancestor/preceding element |
| 862 | function( elem, context, xml ) { |
| 863 | while ( ( elem = elem[ dir ] ) ) { |
| 864 | if ( elem.nodeType === 1 || checkNonElements ) { |
| 865 | return matcher( elem, context, xml ); |
| 866 | } |
| 867 | } |
| 868 | return false; |
| 869 | } : |
| 870 | |
| 871 | // Check against all ancestor/preceding elements |
| 872 | function( elem, context, xml ) { |
| 873 | var oldCache, outerCache, |
| 874 | newCache = [ dirruns, doneName ]; |
| 875 | |
| 876 | // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching |
| 877 | if ( xml ) { |
| 878 | while ( ( elem = elem[ dir ] ) ) { |
| 879 | if ( elem.nodeType === 1 || checkNonElements ) { |
| 880 | if ( matcher( elem, context, xml ) ) { |
| 881 | return true; |
| 882 | } |
| 883 | } |
| 884 | } |
| 885 | } else { |
| 886 | while ( ( elem = elem[ dir ] ) ) { |
| 887 | if ( elem.nodeType === 1 || checkNonElements ) { |
| 888 | outerCache = elem[ jQuery.expando ] || ( elem[ jQuery.expando ] = {} ); |
| 889 | |
| 890 | if ( skip && nodeName( elem, skip ) ) { |
| 891 | elem = elem[ dir ] || elem; |
| 892 | } else if ( ( oldCache = outerCache[ key ] ) && |
| 893 | oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { |
| 894 | |
| 895 | // Assign to newCache so results back-propagate to previous elements |
| 896 | return ( newCache[ 2 ] = oldCache[ 2 ] ); |
| 897 | } else { |
| 898 | |
| 899 | // Reuse newcache so results back-propagate to previous elements |
| 900 | outerCache[ key ] = newCache; |
| 901 | |
| 902 | // A match means we're done; a fail means we have to keep checking |
| 903 | if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { |
| 904 | return true; |
| 905 | } |
| 906 | } |
| 907 | } |
| 908 | } |
| 909 | } |
no test coverage detected