X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fcss.js;h=77949aebc60f56fa4237c0f61cbc738d5023a0e9;hb=0da700a4d03c1c43e75e3ab7f8e719e13c7e444a;hp=84b6e6023f2321c01763bd84ca5d0bac1be41ccd;hpb=77e310b906112c9e20dfbf0e91249a0b81cf6107;p=jquery.git diff --git a/src/css.js b/src/css.js index 84b6e60..77949ae 100644 --- a/src/css.js +++ b/src/css.js @@ -155,7 +155,7 @@ jQuery.each(["height", "width"], function( i, name ) { }, set: function( elem, value ) { - if ( value !== "" ) { + if ( rnumpx.test( value ) ) { // ignore negative width and height values #1599 value = parseFloat(value); @@ -174,7 +174,7 @@ if ( !jQuery.support.opacity ) { jQuery.cssHooks.opacity = { get: function( elem, computed ) { // IE uses filters for opacity - return ropacity.test((computed ? elem.currentStyle.filter : elem.style.filter) || "") ? + return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? (parseFloat(RegExp.$1) / 100) + "" : "1"; }, @@ -187,11 +187,11 @@ if ( !jQuery.support.opacity ) { style.zoom = 1; // Set the alpha filter to set the opacity - var opacity = parseInt( value, 10 ) + "" === "NaN" ? + var opacity = isNaN(value) ? "" : "alpha(opacity=" + value * 100 + ")"; - var filter = style.filter || elem.currentStyle.filter || ""; + var filter = style.filter || elem.currentStyle && elem.currentStyle.filter || ""; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : @@ -219,7 +219,7 @@ if ( getComputedStyle ) { } else if ( document.documentElement.currentStyle ) { curCSS = function( elem, name ) { - var left, rsLeft, ret = elem.currentStyle[ name ], style = elem.style; + var left, rsLeft, ret = elem.currentStyle && elem.currentStyle[ name ], style = elem.style; // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291