MCPcopy
hub / github.com/layui/layui / tokenize

Function tokenize

src/modules/jquery.js:2141–2215  ·  view source on GitHub ↗
(selector, parseOnly)

Source from the content-addressed store, hash-verified

2139 Expr.setFilters = new setFilters();
2140
2141 function tokenize(selector, parseOnly) {
2142 var matched,
2143 match,
2144 tokens,
2145 type,
2146 soFar,
2147 groups,
2148 preFilters,
2149 cached = tokenCache[selector + ' '];
2150
2151 if (cached) {
2152 return parseOnly ? 0 : cached.slice(0);
2153 }
2154
2155 soFar = selector;
2156 groups = [];
2157 preFilters = Expr.preFilter;
2158
2159 while (soFar) {
2160 // Comma and first run
2161 if (!matched || (match = rcomma.exec(soFar))) {
2162 if (match) {
2163 // Don't consume trailing commas as valid
2164 soFar = soFar.slice(match[0].length) || soFar;
2165 }
2166 groups.push((tokens = []));
2167 }
2168
2169 matched = false;
2170
2171 // Combinators
2172 if ((match = rleadingCombinator.exec(soFar))) {
2173 matched = match.shift();
2174 tokens.push({
2175 value: matched,
2176
2177 // Cast descendant combinators to space
2178 type: match[0].replace(rtrimCSS, ' ')
2179 });
2180 soFar = soFar.slice(matched.length);
2181 }
2182
2183 // Filters
2184 for (type in Expr.filter) {
2185 if (
2186 (match = matchExpr[type].exec(soFar)) &&
2187 (!preFilters[type] || (match = preFilters[type](match)))
2188 ) {
2189 matched = match.shift();
2190 tokens.push({
2191 value: matched,
2192 type: type,
2193 matches: match
2194 });
2195 soFar = soFar.slice(matched.length);
2196 }
2197 }
2198

Callers 4

findFunction · 0.85
jquery.jsFile · 0.85
compileFunction · 0.85
selectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected