mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Opera doesn't give height/width of display: none elements with getComputedStyle but does with currentStyle - fall back to that if it exists.
This commit is contained in:
parent
62c83a764c
commit
fb4445070c
19
src/css.js
19
src/css.js
@ -12,8 +12,8 @@ var ralpha = /alpha\([^)]*\)/i,
|
|||||||
cssHeight = [ "Top", "Bottom" ],
|
cssHeight = [ "Top", "Bottom" ],
|
||||||
curCSS,
|
curCSS,
|
||||||
|
|
||||||
// cache check for defaultView.getComputedStyle
|
getComputedStyle,
|
||||||
getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
|
currentStyle,
|
||||||
|
|
||||||
fcamelCase = function( all, letter ) {
|
fcamelCase = function( all, letter ) {
|
||||||
return letter.toUpperCase();
|
return letter.toUpperCase();
|
||||||
@ -172,6 +172,10 @@ jQuery.each(["height", "width"], function( i, name ) {
|
|||||||
if ( val <= 0 ) {
|
if ( val <= 0 ) {
|
||||||
val = curCSS( elem, name, name );
|
val = curCSS( elem, name, name );
|
||||||
|
|
||||||
|
if ( val === "0px" && currentStyle ) {
|
||||||
|
val = currentStyle( elem, name, name );
|
||||||
|
}
|
||||||
|
|
||||||
if ( val != null ) {
|
if ( val != null ) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -231,8 +235,8 @@ if ( !jQuery.support.opacity ) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getComputedStyle ) {
|
if ( document.defaultView && document.defaultView.getComputedStyle ) {
|
||||||
curCSS = function( elem, newName, name ) {
|
getComputedStyle = function( elem, newName, name ) {
|
||||||
var ret, defaultView, computedStyle;
|
var ret, defaultView, computedStyle;
|
||||||
|
|
||||||
name = name.replace( rupper, "-$1" ).toLowerCase();
|
name = name.replace( rupper, "-$1" ).toLowerCase();
|
||||||
@ -250,9 +254,10 @@ if ( getComputedStyle ) {
|
|||||||
|
|
||||||
return ret === "" ? "auto" : ret;
|
return ret === "" ? "auto" : ret;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
} else if ( document.documentElement.currentStyle ) {
|
if ( document.documentElement.currentStyle ) {
|
||||||
curCSS = function( elem, name ) {
|
currentStyle = function( elem, name ) {
|
||||||
var left, rsLeft, ret = elem.currentStyle && 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
|
// From the awesome hack by Dean Edwards
|
||||||
@ -279,6 +284,8 @@ if ( getComputedStyle ) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curCSS = getComputedStyle || currentStyle;
|
||||||
|
|
||||||
function getWH( elem, name, extra ) {
|
function getWH( elem, name, extra ) {
|
||||||
var which = name === "width" ? cssWidth : cssHeight,
|
var which = name === "width" ? cssWidth : cssHeight,
|
||||||
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
|
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
|
||||||
|
Loading…
Reference in New Issue
Block a user