( selector, context, results, seed )
| 736 | } |
| 737 | |
| 738 | function 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 |
no test coverage detected