MCPcopy
hub / github.com/perkeep/perkeep / Sizzle

Function Sizzle

app/publisher/jquery.js:738–870  ·  view source on GitHub ↗
( selector, context, results, seed )

Source from the content-addressed store, hash-verified

736}
737
738function Sizzle( selector, context, results, seed ) {
739 var m, i, elem, nid, nidselect, match, groups, newSelector,
740 newContext = context && context.ownerDocument,
741
742 // nodeType defaults to 9, since context defaults to document
743 nodeType = context ? context.nodeType : 9;
744
745 results = results || [];
746
747 // Return early from calls with invalid selector or context
748 if ( typeof selector !== "string" || !selector ||
749 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
750
751 return results;
752 }
753
754 // Try to shortcut find operations (as opposed to filters) in HTML documents
755 if ( !seed ) {
756
757 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
758 setDocument( context );
759 }
760 context = context || document;
761
762 if ( documentIsHTML ) {
763
764 // If the selector is sufficiently simple, try using a "get*By*" DOM method
765 // (excepting DocumentFragment context, where the methods don't exist)
766 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
767
768 // ID selector
769 if ( (m = match[1]) ) {
770
771 // Document context
772 if ( nodeType === 9 ) {
773 if ( (elem = context.getElementById( m )) ) {
774
775 // Support: IE, Opera, Webkit
776 // TODO: identify versions
777 // getElementById can match elements by name instead of ID
778 if ( elem.id === m ) {
779 results.push( elem );
780 return results;
781 }
782 } else {
783 return results;
784 }
785
786 // Element context
787 } else {
788
789 // Support: IE, Opera, Webkit
790 // TODO: identify versions
791 // getElementById can match elements by name instead of ID
792 if ( newContext && (elem = newContext.getElementById( m )) &&
793 contains( context, elem ) &&
794 elem.id === m ) {
795

Callers 2

jquery.jsFile · 0.85
multipleContextsFunction · 0.85

Calls 4

toSelectorFunction · 0.85
testContextFunction · 0.85
setAttributeMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected