X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fcss.js;h=f77497b4fb3866e1d00353cb5cd2a00b86372e69;hb=31b573185b7728fa74452fbecc515c6de94640a6;hp=9551bc949e98c856c6a764d658f37761ce5a328b;hpb=d7d908b05a442745c1a90728805b74db0a7921cf;p=jquery.git diff --git a/src/css.js b/src/css.js index 9551bc9..f77497b 100644 --- a/src/css.js +++ b/src/css.js @@ -1,17 +1,13 @@ // exclude the following css properties to add px var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, - // cache defaultView - defaultView = document.defaultView || {}, + // cache check for defaultView.getComputedStyle + getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, // normalize float css property styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; jQuery.fn.css = function( name, value ) { var options = name, isFunction = jQuery.isFunction( value ); - // ignore negative width and height values - if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 ) - value = undefined; - if ( typeof name === "string" ) { // Are we setting the style? if ( value === undefined ) { @@ -55,6 +51,10 @@ jQuery.extend({ if (!elem || elem.nodeType == 3 || elem.nodeType == 8) return undefined; + // ignore negative width and height values #1599 + if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 ) + value = undefined; + var style = elem.style || elem, set = value !== undefined; // IE uses filters for opacity @@ -140,7 +140,7 @@ jQuery.extend({ if ( !force && style && style[ name ] ) { ret = style[ name ]; - } else if ( defaultView.getComputedStyle ) { + } else if ( getComputedStyle ) { // Only "float" is needed here if ( /float/i.test( name ) ) @@ -148,7 +148,7 @@ jQuery.extend({ name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); - var computedStyle = defaultView.getComputedStyle( elem, null ); + var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); if ( computedStyle ) ret = computedStyle.getPropertyValue( name );