MCPcopy
hub / github.com/apache/caldera / Sizzle

Function Sizzle

static/jquery/jquery.js:772–904  ·  view source on GitHub ↗
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

770}
771
772function Sizzle( selector, context, results, seed ) {
773 var m, i, elem, nid, nidselect, match, groups, newSelector,
774 newContext = context && context.ownerDocument,
775
776 // nodeType defaults to 9, since context defaults to document
777 nodeType = context ? context.nodeType : 9;
778
779 results = results || [];
780
781 // Return early from calls with invalid selector or context
782 if ( typeof selector !== "string" || !selector ||
783 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
784
785 return results;
786 }
787
788 // Try to shortcut find operations (as opposed to filters) in HTML documents
789 if ( !seed ) {
790
791 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
792 setDocument( context );
793 }
794 context = context || document;
795
796 if ( documentIsHTML ) {
797
798 // If the selector is sufficiently simple, try using a "get*By*" DOM method
799 // (excepting DocumentFragment context, where the methods don't exist)
800 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
801
802 // ID selector
803 if ( (m = match[1]) ) {
804
805 // Document context
806 if ( nodeType === 9 ) {
807 if ( (elem = context.getElementById( m )) ) {
808
809 // Support: IE, Opera, Webkit
810 // TODO: identify versions
811 // getElementById can match elements by name instead of ID
812 if ( elem.id === m ) {
813 results.push( elem );
814 return results;
815 }
816 } else {
817 return results;
818 }
819
820 // Element context
821 } else {
822
823 // Support: IE, Opera, Webkit
824 // TODO: identify versions
825 // getElementById can match elements by name instead of ID
826 if ( newContext && (elem = newContext.getElementById( m )) &&
827 contains( context, elem ) &&
828 elem.id === m ) {
829

Callers 2

jquery.jsFile · 0.85
multipleContextsFunction · 0.85

Calls 5

toSelectorFunction · 0.85
testContextFunction · 0.85
testMethod · 0.80
replaceMethod · 0.80
applyMethod · 0.45

Tested by

no test coverage detected