X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=f4d2ef728a33b8724acc8f44fee0228f0882e824;hb=34c0bed54a5ad812b1f78a85529164e0085f50d7;hp=f756b67ab78e08f54831061b9e2c51fd20793082;hpb=3362ccf3ddc20d787551ffdb441ae606a3d06630;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index f756b67..f4d2ef7 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -32,14 +32,13 @@ var jQuery = function(a,c) { // HANDLE: $(function) // Shortcut for document ready - // Safari reports typeof on DOM NodeLists as a function - if ( jQuery.isFunction(a) && !a.nodeType && a[0] == undefined ) + if ( jQuery.isFunction(a) ) return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a ); // Handle HTML strings if ( typeof a == "string" ) { // HANDLE: $(html) -> $(array) - var m = /^[^<]*(<.+>)[^>]*$/.exec(a); + var m = /^[^<]*(<(.|\n)+>)[^>]*$/.exec(a); if ( m ) a = jQuery.clean( [ m[1] ] ); @@ -429,7 +428,7 @@ jQuery.fn = jQuery.prototype = { // Look for the case where we're accessing a style value if ( key.constructor == String ) if ( value == undefined ) - return jQuery[ type || "attr" ]( this[0], key ); + return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined; else { obj = {}; obj[ key ] = value; @@ -985,7 +984,10 @@ jQuery.fn = jQuery.prototype = { add: function(t) { return this.pushStack( jQuery.merge( this.get(), - typeof t == "string" ? jQuery(t).get() : t.length ? t : [t] ) + t.constructor == String ? + jQuery(t).get() : + t.length != undefined && !t.nodeName ? + t : [t] ) ); }, @@ -1217,10 +1219,14 @@ jQuery.extend({ noConflict: function() { if ( jQuery._$ ) $ = jQuery._$; + return jQuery; }, + // This may seem like some crazy code, but trust me when I say that this + // is the only cross-browser way to do this. --John isFunction: function( fn ) { - return fn && typeof fn == "function"; + return !!fn && typeof fn != "string" && + typeof fn[0] == "undefined" && /function/i.test( fn + "" ); }, /** @@ -1268,7 +1274,7 @@ jQuery.extend({ return value.call( elem, [index] ); // exclude the following css properties to add px - var exclude = /z-?index|font-?weight|opacity/i; + var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; // Handle passing in a number to a CSS property if ( value.constructor == Number && type == "curCSS" && !exclude.test(prop) )