// 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 ) {
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
},
curCSS: function( elem, name, force ) {
- var ret, style = elem.style;
+ var ret, style = elem.style, filter;
// IE uses filters for opacity
- if ( !jQuery.support.opacity && name == "opacity" ) {
- ret = style.filter && style.filter.indexOf("opacity=") >= 0 ?
- (parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = (elem.currentStyle.filter || "").match(/opacity=([^)]*)/) ?
+ (parseFloat(RegExp.$1) / 100) + "" :
"";
return ret === "" ?
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 ) )
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 );