X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=jquery%2Fjquery.js;h=b3e28edb230dc2c8239179469fbb50dcf1c0d93e;hb=4737936c0b05236ecafa86f0186b0b236a2ff826;hp=983148a149a2cd6f3c66b4f1ff5c33af7626571b;hpb=7d57c67749a4c38d80de6d5ed7917f4219ce34b4;p=jquery.git diff --git a/jquery/jquery.js b/jquery/jquery.js index 983148a..b3e28ed 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -61,7 +61,7 @@ function jQuery(a,c) { if ( m ) a = jQuery.clean( [ m[1] ] ); // Watch for when an array is passed in - this.get( a.constructor == Array || a.length && a[0].nodeType ? + this.get( a.constructor == Array || a.length && a[0] != undefined && a[0].nodeType ? // Assume that it's an array of DOM Elements jQuery.merge( a, [] ) : @@ -308,7 +308,7 @@ jQuery.fn = jQuery.prototype = { * @param Object value The value to set the property to. */ css: function( key, value ) { - return this.attr( key, value, "css" ); + return this.attr( key, value, "curCSS" ); }, /** @@ -1107,18 +1107,18 @@ new function() { this.length ? this[0][n] : null : this.attr( n, h ); }; - } - - var css = "width,height,top,left,position,float,overflow,color,background".split(","); - + }; + + var css = "width,height,top,left,position,float,overflow,color,background".split(","); + for ( var i in css ) new function() { var n = css[i]; jQuery.fn[ i ] = function(h) { return h == undefined ? - this.length ? jQuery.css( this[0], n ) : null : + ( this.length ? jQuery.css( this[0], n ) : null ) : this.css( n, h ); }; - } + }; } @@ -1177,7 +1177,11 @@ jQuery.extend({ return p == "height" ? oHeight : oWidth; } - + + return jQuery.curCSS( e, p ); + }, + + curCSS: function(e,p) { var r; if (e.style[p]) @@ -1252,8 +1256,8 @@ jQuery.extend({ contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0", // Visibility - visible: "jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'", - hidden: "jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'", + 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'", // Form elements enabled: "!a.disabled", @@ -1405,50 +1409,53 @@ jQuery.extend({ } else return ""; }, + + // The regular expressions that power the parsing engine + parse: [ + // Match: [@value='test'], [@foo] + [ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ], + + // Match: [div], [div p] + [ "(\\[)Q\\]", 0 ], + + // Match: :contains('foo') + [ "(:)S\\(Q\\)", 0 ], + + // Match: :even, :last-chlid + [ "([:.#]*)S", 0 ] + ], filter: function(t,r,not) { // Figure out if we're doing regular, or inverse, filtering var g = not !== false ? jQuery.grep : function(a,f) {return jQuery.grep(a,f,true);}; - // Look for a string-like sequence - var str = "([a-zA-Z*_-][a-zA-Z0-9_-]*)"; - - // Look for something (optionally) enclosed with quotes - var qstr = " *'?\"?([^'\"]*)'?\"? *"; - - while ( t && /^[a-zA-Z\[*:.#]/.test(t) ) { - // Handles: - // [@foo], [@foo=bar], etc. - var re = new RegExp("^\\[ *@" + str + " *([!*$^=]*) *" + qstr + "\\]"); - var m = re.exec(t); - - // Re-organize the match - if ( m ) m = ["", "@", m[2], m[1], m[3]]; - - // Handles: - // [div], [.foo] - if ( !m ) { - re = new RegExp("^(\\[)" + qstr + "\\]"); - m = re.exec(t); - } - - // Handles: - // :contains(test), :not(.foo) - if ( !m ) { - re = new RegExp("^(:)" + str + "\\(" + qstr + "\\)"); - m = re.exec(t); - } - - // Handles: - // :foo, .foo, #foo, foo - if ( !m ) { - re = new RegExp("^([:.#]*)" + str); - m = re.exec(t); + while ( t && /^[a-z[({<*:.#]/i.test(t) ) { + + var p = jQuery.parse; + + for ( var i = 0; i < p.length; i++ ) { + var re = new RegExp( "^" + p[i][0] + + // Look for a string-like sequence + .replace( 'S', "([a-z*_-][a-z0-9_-]*)" ) + + // Look for something (optionally) enclosed with quotes + .replace( 'Q', " *'?\"?([^'\"]*)'?\"? *" ), "i" ); + + var m = re.exec( t ); + + if ( m ) { + // Re-organize the match + if ( p[i][1] ) + m = ["", m[1], m[3], m[2], m[4]]; + + // Remove what we just matched + t = t.replace( re, "" ); + + break; + } } - - // Remove what we just matched - t = t.replace( re, "" ); // :not() is a special case that can be optomized by // keeping it out of the expression list