MCPcopy Create free account
hub / github.com/JsAaron/jQuery / select

Function select

2.0.3/Sizzle.js:1891–1952  ·  view source on GitHub ↗
(selector, context, results, seed)

Source from the content-addressed store, hash-verified

1889 }
1890
1891 function select(selector, context, results, seed) {
1892 var i, tokens, token, type, find,
1893 match = tokenize(selector);
1894
1895 if (!seed) {
1896 // Try to minimize operations if there is only one group
1897 if (match.length === 1) {
1898
1899 // Take a shortcut and set the context if the root selector is an ID
1900 tokens = match[0] = match[0].slice(0);
1901 if (tokens.length > 2 && (token = tokens[0]).type === "ID" &&
1902 support.getById && context.nodeType === 9 && documentIsHTML &&
1903 Expr.relative[tokens[1].type]) {
1904
1905 context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0];
1906 if (!context) {
1907 return results;
1908 }
1909 selector = selector.slice(tokens.shift().value.length);
1910 }
1911
1912 // Fetch a seed set for right-to-left matching
1913 i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length;
1914 while (i--) {
1915 token = tokens[i];
1916
1917 // Abort if we hit a combinator
1918 if (Expr.relative[(type = token.type)]) {
1919 break;
1920 }
1921 if ((find = Expr.find[type])) {
1922 // Search, expanding context for leading sibling combinators
1923 if ((seed = find(
1924 token.matches[0].replace(runescape, funescape),
1925 rsibling.test(tokens[0].type) && context.parentNode || context
1926 ))) {
1927
1928 // If seed is empty or no tokens remain, we can return early
1929 tokens.splice(i, 1);
1930 selector = seed.length && toSelector(tokens);
1931 if (!selector) {
1932 push.apply(results, seed);
1933 return results;
1934 }
1935
1936 break;
1937 }
1938 }
1939 }
1940 }
1941 }
1942
1943 // Compile and execute a filtering function
1944 // Provide `match` to avoid retokenization if we modified the selector above
1945 compile(selector, match)(
1946 seed,
1947 context, !documentIsHTML,
1948 results,

Callers 1

SizzleFunction · 0.70

Calls 2

tokenizeFunction · 0.70
toSelectorFunction · 0.70

Tested by

no test coverage detected