- visible: 'a.type!="hidden"&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
- hidden: 'a.type=="hidden"||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
+ visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
+ hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
- text: "a.type=='text'",
- radio: "a.type=='radio'",
- checkbox: "a.type=='checkbox'",
- file: "a.type=='file'",
- password: "a.type=='password'",
- submit: "a.type=='submit'",
- image: "a.type=='image'",
- reset: "a.type=='reset'",
- button: 'a.type=="button"||jQuery.nodeName(a,"button")',
+ text: "'text'==a.type",
+ radio: "'radio'==a.type",
+ checkbox: "'checkbox'==a.type",
+ file: "'file'==a.type",
+ password: "'password'==a.type",
+ submit: "'submit'==a.type",
+ image: "'image'==a.type",
+ reset: "'reset'==a.type",
+ button: '"button"==a.type||jQuery.nodeName(a,"button")',
input: "/input|select|textarea|button/i.test(a.nodeName)"
},
".": "jQuery.className.has(a,m[2])",
input: "/input|select|textarea|button/i.test(a.nodeName)"
},
".": "jQuery.className.has(a,m[2])",
_resort: function(m){
return ["", m[1], m[3], m[2], m[5]];
},
_resort: function(m){
return ["", m[1], m[3], m[2], m[5]];
},
// The regular expressions that power the parsing engine
parse: [
// Match: [@value='test'], [@foo]
// The regular expressions that power the parsing engine
parse: [
// Match: [@value='test'], [@foo]
// Match: [div], [div p]
/^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
// Match: :contains('foo')
// Match: [div], [div p]
/^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
// Match: :contains('foo')
// Match: :even, :last-chlid, #id, .class
// Match: :even, :last-chlid, #id, .class
- jQuery.each( ret, function(){
- for ( var c = this.firstChild; c; c = c.nextSibling )
- if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
+ for ( var i = 0; ret[i]; i++ )
+ for ( var c = ret[i].firstChild; c; c = c.nextSibling )
+ if ( c.nodeType == 1 && ( m[1] == "*" || jQuery.nodeName(c, m[1]) ) )
- 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 ) );
} else {
// Otherwise, do a traditional filter check for
// ID, class, and element selectors
} else {
// Otherwise, do a traditional filter check for
// ID, class, and element selectors
var elem = ret[ret.length-1];
// Try to do a global search by ID, where we can
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
// Do a quick check for the existence of the actual ID attribute
// to avoid selecting by the name attribute in IE
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
// Do a quick check for node name (where applicable) so
// that div#foo searches will be really fast
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
// Do a quick check for node name (where applicable) so
// that div#foo searches will be really fast
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
- // 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
- for ( var i = 0, rl = ret.length; i < rl; i++ ) {
+ // We need to find all descendant elements
+ for ( var i = 0; ret[i]; i++ ) {
- // Remember, then wipe out, the result set
- var tmp = r;
- r = [];
-
- // Then try to find the element with the ID
- jQuery.each( tmp, function(){
- if ( this.getAttribute("id") == m[2] ) {
- r = [ this ];
- return false;
+ var tmp = [];
+
+ // Try to find the element with the ID
+ for ( var i = 0; r[i]; i++ )
+ if ( r[i].getAttribute("id") == m[2] ) {
+ tmp = [ r[i] ];
+ break;
+ classFilter: function(r,m,not){
+ m = " " + m + " ";
+ var tmp = [];
+ for ( var i = 0; r[i]; i++ ) {
+ var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
+ if ( !not && pass || not && !pass )
+ tmp.push( r[i] );
+ }
+ return tmp;
+ },
+
- jQuery.each( p, function(i,re){
-
- // Look for, and replace, string-like sequences
- // and finally build a regexp out of it
- m = re.exec( t );
+ for ( var i = 0; p[i]; i++ ) {
+ m = p[i].exec( t );
// :not() is a special case that can be optimized by
// keeping it out of the expression list
if ( m[1] == ":" && m[2] == "not" )
r = jQuery.filter(m[3], r, true).r;
// :not() is a special case that can be optimized by
// keeping it out of the expression list
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);
+ // We can get a big speed boost by filtering by class here
+ else if ( m[1] == "." )
+ r = jQuery.classFilter(r, m[2], not);
var f = jQuery.expr[m[1]];
if ( typeof f != "string" )
f = jQuery.expr[m[1]][m[2]];
var f = jQuery.expr[m[1]];
if ( typeof f != "string" )
f = jQuery.expr[m[1]][m[2]];
for ( ; cur; cur = cur[dir] ) {
if ( cur.nodeType == 1 ) num++;
if ( num == result || result == "even" && num % 2 == 0 && num > 1 && cur == elem ||
for ( ; cur; cur = cur[dir] ) {
if ( cur.nodeType == 1 ) num++;
if ( num == result || result == "even" && num % 2 == 0 && num > 1 && cur == elem ||