-/*
- * Sizzle CSS Selector Engine - v0.9
- * Copyright 2009, John Resig (http://ejohn.org/)
- * released under the MIT License
+/*!
+ * Sizzle CSS Selector Engine - v0.9.1
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
*/
(function(){
-var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g;
-
-var done = 0;
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,
+ done = 0,
+ toString = Object.prototype.toString;
var Sizzle = function(selector, context, results, seed) {
- var doCache = !results;
results = results || [];
context = context || document;
pop = context;
}
- Expr.relative[ cur ]( checkSet, pop );
+ Expr.relative[ cur ]( checkSet, pop, isXML(context) );
}
}
throw "Syntax error, unrecognized expression: " + (cur || selector);
}
- if ( checkSet instanceof Array ) {
+ if ( toString.call(checkSet) === "[object Array]" ) {
if ( !prune ) {
results.push.apply( results, checkSet );
} else if ( context.nodeType === 1 ) {
var Expr = Sizzle.selectors = {
order: [ "ID", "NAME", "TAG" ],
match: {
- ID: /#((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
- CLASS: /\.((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
- NAME: /\[name=['"]*((?:[\w\u0128-\uFFFF_-]|\\.)+)['"]*\]/,
- ATTR: /\[((?:[\w\u0128-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\]/,
- TAG: /^((?:[\w\u0128-\uFFFF\*_-]|\\.)+)/,
- CHILD: /:(only|nth|last|first)-child\(?(even|odd|[\dn+-]*)\)?/,
- POS: /:(nth|eq|gt|lt|first|last|even|odd)\(?(\d*)\)?(?:[^-]|$)/,
- PSEUDO: /:((?:[\w\u0128-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
+ ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
+ ATTR: /\[((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
},
attrMap: {
- "class": "className"
+ "class": "className",
+ "for": "htmlFor"
},
relative: {
"+": function(checkSet, part){
Sizzle.filter( part, checkSet, true );
}
},
- ">": function(checkSet, part){
+ ">": function(checkSet, part, isXML){
if ( typeof part === "string" && !/\W/.test(part) ) {
- part = part.toUpperCase();
+ part = isXML ? part : part.toUpperCase();
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
}
}
},
- "": function(checkSet, part){
+ "": function(checkSet, part, isXML){
var doneName = "done" + (done++), checkFn = dirCheck;
if ( !part.match(/\W/) ) {
- var nodeCheck = part = part.toUpperCase();
+ var nodeCheck = part = isXML ? part : part.toUpperCase();
checkFn = dirNodeCheck;
}
checkFn("parentNode", part, doneName, checkSet, nodeCheck);
},
- "~": function(checkSet, part){
+ "~": function(checkSet, part, isXML){
var doneName = "done" + (done++), checkFn = dirCheck;
if ( typeof part === "string" && !part.match(/\W/) ) {
- var nodeCheck = part = part.toUpperCase();
+ var nodeCheck = part = isXML ? part : part.toUpperCase();
checkFn = dirNodeCheck;
}
return false;
},
ID: function(match){
- return match[1];
+ return match[1].replace(/\\/g, "");
},
- TAG: function(match){
- return match[1].toUpperCase();
+ TAG: function(match, curLoop){
+ for ( var i = 0; !curLoop[i]; i++ ){}
+ return isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
},
CHILD: function(match){
if ( match[1] == "nth" ) {
makeArray = function(array, results) {
var ret = results || [];
- if ( array instanceof Array ) {
+ if ( toString.call(array) === "[object Array]" ) {
Array.prototype.push.apply( ret, array );
} else {
if ( typeof array.length === "number" ) {
return a !== b && (a.contains ? a.contains(b) : true);
};
+var isXML = function(elem){
+ return elem.documentElement && !elem.body ||
+ elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+};
+
// EXPOSE
jQuery.find = Sizzle;
jQuery.filter = Sizzle.filter;