MCPcopy Index your code
hub / github.com/JsAaron/jQuery / Sizzle

Function Sizzle

2.1.1/test/sizzle.js:195–306  ·  view source on GitHub ↗
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

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

Callers 2

sizzle.jsFile · 0.70
multipleContextsFunction · 0.70

Calls 4

toSelectorFunction · 0.70
testContextFunction · 0.70
selectFunction · 0.50
tokenizeFunction · 0.50

Tested by

no test coverage detected