MCPcopy Create free account
hub / github.com/nwutils/nw-sample-apps / Sizzle

Function Sizzle

camera/jquery.js:737–844  ·  view source on GitHub ↗
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

735}
736
737function Sizzle( selector, context, results, seed ) {
738 var match, elem, m, nodeType,
739 // QSA vars
740 i, groups, old, nid, newContext, newSelector;
741
742 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
743 setDocument( context );
744 }
745
746 context = context || document;
747 results = results || [];
748
749 if ( !selector || typeof selector !== "string" ) {
750 return results;
751 }
752
753 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
754 return [];
755 }
756
757 if ( documentIsHTML && !seed ) {
758
759 // Shortcuts
760 if ( (match = rquickExpr.exec( selector )) ) {
761 // Speed-up: Sizzle("#ID")
762 if ( (m = match[1]) ) {
763 if ( nodeType === 9 ) {
764 elem = context.getElementById( m );
765 // Check parentNode to catch when Blackberry 4.6 returns
766 // nodes that are no longer in the document (jQuery #6963)
767 if ( elem && elem.parentNode ) {
768 // Handle the case where IE, Opera, and Webkit return items
769 // by name instead of ID
770 if ( elem.id === m ) {
771 results.push( elem );
772 return results;
773 }
774 } else {
775 return results;
776 }
777 } else {
778 // Context is not a document
779 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
780 contains( context, elem ) && elem.id === m ) {
781 results.push( elem );
782 return results;
783 }
784 }
785
786 // Speed-up: Sizzle("TAG")
787 } else if ( match[2] ) {
788 push.apply( results, context.getElementsByTagName( selector ) );
789 return results;
790
791 // Speed-up: Sizzle(".CLASS")
792 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
793 push.apply( results, context.getElementsByClassName( m ) );
794 return results;

Callers 2

jquery.jsFile · 0.70
multipleContextsFunction · 0.70

Calls 3

toSelectorFunction · 0.85
testContextFunction · 0.85
tokenizeFunction · 0.50

Tested by

no test coverage detected