- 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
- /^([:.#]*)([a-z0-9_*-]*)/i
+ // Match: :even, :last-chlid, #id, .class
+ new RegExp("^([:.#]*)(" +
+ ( jQuery.chars = "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)" ) + "+)")
t = t.substr(2,t.length);
// And the / root expression
t = t.substr(2,t.length);
// And the / root expression
context = context.documentElement;
t = t.substr(1,t.length);
if ( t.indexOf("/") >= 1 )
context = context.documentElement;
t = t.substr(1,t.length);
if ( t.indexOf("/") >= 1 )
// Continue while a selector expression exists, and while
// we're no longer looping upon ourselves
// Continue while a selector expression exists, and while
// we're no longer looping upon ourselves
- 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 oid = ret[ret.length-1].getElementById(m[2]);
+ var oid = elem.getElementById(m[2]);
+
+ // 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||jQuery.browser.opera) && oid && oid.id != m[2] )
+ oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
- // 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
- jQuery.each( ret, function(){
+ // We need to find all descendant elements
+ for ( var i = 0; ret[i]; i++ ) {
// Grab the tag name being searched for
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
// Handle IE7 being really dumb about <object>s
// Grab the tag name being searched for
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
// Handle IE7 being really dumb about <object>s
- jQuery.merge( r,
- m[1] != "" && ret.length != 1 ?
- jQuery.getAll( this, [], m[1], m[2], rec ) :
- this.getElementsByTagName( tag )
- );
- });
+ r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
+ }
- if ( m[1] == "." && ret.length == 1 )
- r = jQuery.grep( r, function(e) {
- return rec.test(e.className);
- });
+ if ( m[1] == "." )
+ r = jQuery.classFilter( r, m[2] );
- if ( m[1] == "#" && ret.length == 1 ) {
- // 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;
+ if ( m[1] == "#" ) {
+ 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]];
-
- getAll: function( o, r, token, name, re ) {
- for ( var s = o.firstChild; s; s = s.nextSibling )
- if ( s.nodeType == 1 ) {
- var add = true;
-
- if ( token == "." )
- add = s.className && re.test(s.className);
- else if ( token == "#" )
- add = s.getAttribute("id") == name;
-
- if ( add )
- r.push( s );
-
- if ( token == "#" && r.length ) break;
-
- if ( s.firstChild )
- jQuery.getAll( s, r, token, name, re );
- }
-
- return r;
- },
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 ||