}
}
- expr = expr.replace(/\s*,\s*/, "");
-
// Improper expression
if ( expr == old ) {
if ( anyFound == null ) {
}
},
NAME: function(match, context, isXML){
- if ( typeof context.getElementsByName !== "undefined" && !isXML ) {
- return context.getElementsByName(match[1]);
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = context.getElementsByName(match[1]);
+ return ret.length === 0 ? null : ret;
}
},
TAG: function(match, context){
PSEUDO: function(match, curLoop, inplace, result, not){
if ( match[1] === "not" ) {
// If we're dealing with a complex expression, or a simple one
- if ( match[3].match(chunker).length > 1 ) {
+ if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) {
match[3] = Sizzle(match[3], null, null, curLoop);
} else {
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
var sortOrder;
-if ( document.documentElement.compareDocumentPosition ) {
+if ( Array.prototype.indexOf ) {
+ var indexOf = Array.prototype.indexOf,
+ allSort = document.getElementsByTagName("*");
+
sortOrder = function( a, b ) {
- var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ var ret = indexOf.call( allSort, a ) - indexOf.call( allSort, b );
if ( ret === 0 ) {
hasDuplicate = true;
}
}
return ret;
};
-} else if ( Array.prototype.indexOf ) {
- var indexOf = Array.prototype.indexOf,
- allSort = document.getElementsByTagName("*");
-
- sortOrder = function( a, b ) {
- var ret = indexOf.call( allSort, a ) - indexOf.call( allSort, b );
- if ( ret === 0 ) {
- hasDuplicate = true;
- }
- return ret;
- };
}
// Check to see if the browser returns elements by name when