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

Function Sizzle

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

Source from the content-addressed store, hash-verified

184 }
185
186 function Sizzle(selector, context, results, seed) {
187 var match, elem, m, nodeType,
188 // QSA vars
189 i, groups, old, nid, newContext, newSelector;
190
191 if ((context ? context.ownerDocument || context : preferredDoc) !== document) {
192 setDocument(context);
193 }
194
195 context = context || document;
196 results = results || [];
197
198 if (!selector || typeof selector !== "string") {
199 return results;
200 }
201
202 if ((nodeType = context.nodeType) !== 1 && nodeType !== 9) {
203 return [];
204 }
205
206 if (documentIsHTML && !seed) {
207
208 // Shortcuts
209 if ((match = rquickExpr.exec(selector))) {
210 // Speed-up: Sizzle("#ID")
211 if ((m = match[1])) {
212 if (nodeType === 9) {
213 elem = context.getElementById(m);
214 // Check parentNode to catch when Blackberry 4.6 returns
215 // nodes that are no longer in the document #6963
216 if (elem && elem.parentNode) {
217 // Handle the case where IE, Opera, and Webkit return items
218 // by name instead of ID
219 if (elem.id === m) {
220 results.push(elem);
221 return results;
222 }
223 } else {
224 return results;
225 }
226 } else {
227 // Context is not a document
228 if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) &&
229 contains(context, elem) && elem.id === m) {
230 results.push(elem);
231 return results;
232 }
233 }
234
235 // Speed-up: Sizzle("TAG")
236 } else if (match[2]) {
237 push.apply(results, context.getElementsByTagName(selector));
238 return results;
239
240 // Speed-up: Sizzle(".CLASS")
241 } else if ((m = match[3]) && support.getElementsByClassName && context.getElementsByClassName) {
242 push.apply(results, context.getElementsByClassName(m));
243 return results;

Callers 2

Sizzle.jsFile · 0.70
multipleContextsFunction · 0.70

Calls 3

tokenizeFunction · 0.70
toSelectorFunction · 0.70
selectFunction · 0.70

Tested by

no test coverage detected