diff options
author | jeresig <jeresig@gmail.com> | 2010-11-03 15:39:28 -0400 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-11-03 15:39:28 -0400 |
commit | fb4445070cd9e06929c7b6f27c10dbf42d4a3367 (patch) | |
tree | 00cda8caaa56eb2052e03bce520e07b86e6103e5 /src/css.js | |
parent | 62c83a764cdb3f6e7f6a9b696de1636570df19bf (diff) | |
download | jquery-fb4445070cd9e06929c7b6f27c10dbf42d4a3367.tar.gz jquery-fb4445070cd9e06929c7b6f27c10dbf42d4a3367.zip |
Opera doesn't give height/width of display: none elements with getComputedStyle but does with currentStyle - fall back to that if it exists.
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/css.js b/src/css.js index 0998657b0..0f1491466 100644 --- a/src/css.js +++ b/src/css.js @@ -12,8 +12,8 @@ var ralpha = /alpha\([^)]*\)/i, cssHeight = [ "Top", "Bottom" ], curCSS, - // cache check for defaultView.getComputedStyle - getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, + getComputedStyle, + currentStyle, fcamelCase = function( all, letter ) { return letter.toUpperCase(); @@ -172,6 +172,10 @@ jQuery.each(["height", "width"], function( i, name ) { if ( val <= 0 ) { val = curCSS( elem, name, name ); + if ( val === "0px" && currentStyle ) { + val = currentStyle( elem, name, name ); + } + if ( val != null ) { return val; } @@ -231,8 +235,8 @@ if ( !jQuery.support.opacity ) { }; } -if ( getComputedStyle ) { - curCSS = function( elem, newName, name ) { +if ( document.defaultView && document.defaultView.getComputedStyle ) { + getComputedStyle = function( elem, newName, name ) { var ret, defaultView, computedStyle; name = name.replace( rupper, "-$1" ).toLowerCase(); @@ -250,9 +254,10 @@ if ( getComputedStyle ) { return ret === "" ? "auto" : ret; }; +} -} else if ( document.documentElement.currentStyle ) { - curCSS = function( elem, name ) { +if ( document.documentElement.currentStyle ) { + currentStyle = function( elem, name ) { var left, rsLeft, ret = elem.currentStyle && elem.currentStyle[ name ], style = elem.style; // From the awesome hack by Dean Edwards @@ -279,6 +284,8 @@ if ( getComputedStyle ) { }; } +curCSS = getComputedStyle || currentStyle; + function getWH( elem, name, extra ) { var which = name === "width" ? cssWidth : cssHeight, val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |