( selector, context, results, seed )
| 1030 | } |
| 1031 | |
| 1032 | function Sizzle( selector, context, results, seed ) { |
| 1033 | var m, i, elem, nid, nidselect, match, groups, newSelector, |
| 1034 | newContext = context && context.ownerDocument, |
| 1035 | |
| 1036 | // nodeType defaults to 9, since context defaults to document |
| 1037 | nodeType = context ? context.nodeType : 9; |
| 1038 | |
| 1039 | results = results || []; |
| 1040 | |
| 1041 | // Return early from calls with invalid selector or context |
| 1042 | if ( typeof selector !== "string" || !selector || |
| 1043 | nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
| 1044 | |
| 1045 | return results; |
| 1046 | } |
| 1047 | |
| 1048 | // Try to shortcut find operations (as opposed to filters) in HTML documents |
| 1049 | if ( !seed ) { |
| 1050 | |
| 1051 | if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
| 1052 | setDocument( context ); |
| 1053 | } |
| 1054 | context = context || document; |
| 1055 | |
| 1056 | if ( documentIsHTML ) { |
| 1057 | |
| 1058 | // If the selector is sufficiently simple, try using a "get*By*" DOM method |
| 1059 | // (excepting DocumentFragment context, where the methods don't exist) |
| 1060 | if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
| 1061 | |
| 1062 | // ID selector |
| 1063 | if ( (m = match[1]) ) { |
| 1064 | |
| 1065 | // Document context |
| 1066 | if ( nodeType === 9 ) { |
| 1067 | if ( (elem = context.getElementById( m )) ) { |
| 1068 | |
| 1069 | // Support: IE, Opera, Webkit |
| 1070 | // TODO: identify versions |
| 1071 | // getElementById can match elements by name instead of ID |
| 1072 | if ( elem.id === m ) { |
| 1073 | results.push( elem ); |
| 1074 | return results; |
| 1075 | } |
| 1076 | } else { |
| 1077 | return results; |
| 1078 | } |
| 1079 | |
| 1080 | // Element context |
| 1081 | } else { |
| 1082 | |
| 1083 | // Support: IE, Opera, Webkit |
| 1084 | // TODO: identify versions |
| 1085 | // getElementById can match elements by name instead of ID |
| 1086 | if ( newContext && (elem = newContext.getElementById( m )) && |
| 1087 | contains( context, elem ) && |
| 1088 | elem.id === m ) { |
| 1089 |
no test coverage detected