},
_prefix: "z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQuery.attr(a,m[3]);"
},
- "[": "jQuery.find(m[2],a).length"
+ "[": "parseInt(m[2])?jQuery.nth(a.parentNode.firstChild,parseInt(m[2]),'nextSibling',a)==a:jQuery.find(m[2],a).length"
},
// The regular expressions that power the parsing engine
parse: [
// Match: [@value='test'], [@foo]
- /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
+ /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/,
// Match: [div], [div p]
/^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
// Match: :contains('foo')
- /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
+ /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
// Match: :even, :last-chlid, #id, .class
- /^([:.#]*)([\w\u0128-\uFFFF*-]+)/i
+ new RegExp("^([:.#]*)(" +
+ ( jQuery.chars = "(?:[\\w\u0128-\uFFFF*-]|\\\\.)" ) + "+)")
],
token: [
// An attempt at speeding up child selectors that
// point to a specific element tag
- var re = /^[\/>]\s*([\w*-]+)/i;
+ var re = /^[\/>]\s*([\w*-]+)/;
var m = re.exec(t);
if ( m ) {
for ( var i = 0; i < jQuery.token.length; i += 2 ) {
// Attempt to match each, individual, token in
// the specified order
- var re = jQuery.token[i];
+ var re = jQuery.token[i], fn = jQuery.token[i+1];
var m = re.exec(t);
// If the token match was found
if ( m ) {
// Map it against the token's handler
- r = ret = jQuery.map( ret, jQuery.isFunction( jQuery.token[i+1] ) ?
- jQuery.token[i+1] :
- function(a){ return eval(jQuery.token[i+1]); });
+ r = ret = jQuery.map( ret, jQuery.isFunction( fn ) ?
+ fn : new Function( "a", "return " + fn ) );
// And remove the token
t = jQuery.trim( t.replace( re, "" ) );
} else {
// Optomize for the case nodeName#idName
- var re2 = /^(\w+)(#)([\w\u0128-\uFFFF*-]+)/i;
+ var re2 = new RegExp("^(\\w+)(#)(" + jQuery.chars + "+)");
var m = re2.exec(t);
// Re-organize the results, so that they're consistent
} else {
// Otherwise, do a traditional filter check for
// ID, class, and element selectors
- re2 = /^([#.]?)([\w\u0128-\uFFFF*-]*)/i;
+ re2 = new RegExp("^([#.]?)(" + jQuery.chars + "*)");
m = re2.exec(t);
}
+ m[2] = m[2].replace(/\\/g, "");
+
var elem = ret[ret.length-1];
// Try to do a global search by ID, where we can
// Do a quick check for the existence of the actual ID attribute
// to avoid selecting by the name attribute in IE
- if ( jQuery.browser.msie && oid && oid.id != m[2] )
+ if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && oid.id != m[2] )
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
// Do a quick check for node name (where applicable) so
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
} else {
- // Pre-compile a regular expression to handle class searches
- if ( m[1] == "." )
- var rec = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
-
- // We need to find all descendant elements, it is more
- // efficient to use getAll() when we are already further down
- // the tree - we try to recognize that here
+ // We need to find all descendant elements
for ( var i = 0, rl = ret.length; i < rl; i++ ) {
// Grab the tag name being searched for
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
// It's faster to filter by class and be done with it
if ( m[1] == "." )
r = jQuery.grep( r, function(e) {
- return rec.test(e.className);
+ return jQuery.className.has(e, m[2]);
});
// Same with ID filtering
if ( jQuery.expr[ m[1] ]._resort )
m = jQuery.expr[ m[1] ]._resort( m );
+ m[2] = m[2].replace(/\\/g, "");
+
return false;
}
});
if ( m[1] == ":" && m[2] == "not" )
r = jQuery.filter(m[3], r, true).r;
- // Handle classes as a special case (this will help to
- // improve the speed, as the regexp will only be compiled once)
- else if ( m[1] == "." ) {
-
- var re = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
- r = jQuery.grep( r, function(e){
- return re.test(e.className || "");
- }, not);
-
// Otherwise, find the expression to execute
- } else {
+ else {
var f = jQuery.expr[m[1]];
if ( typeof f != "string" )
f = jQuery.expr[m[1]][m[2]];