aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorJordan Boesch <jboesch26@gmail.com>2011-04-13 22:30:30 -0600
committerJordan Boesch <jboesch26@gmail.com>2011-04-13 22:30:30 -0600
commite64d3d4e5793d84fe93894c90dc11a64810fae24 (patch)
tree7df6d76509e7d7bcb6b05c7b9d62d017420dcf76 /src/css.js
parentca5bc202ac37a8e3d5787b24ea3fdc229143802c (diff)
downloadjquery-e64d3d4e5793d84fe93894c90dc11a64810fae24.tar.gz
jquery-e64d3d4e5793d84fe93894c90dc11a64810fae24.zip
fixing bug 4146 - round 2!
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/css.js b/src/css.js
index c5c01ecac..02bedf0b5 100644
--- a/src/css.js
+++ b/src/css.js
@@ -338,25 +338,39 @@ curCSS = getComputedStyle || currentStyle;
function getWH( elem, name, extra ) {
var which = name === "width" ? cssWidth : cssHeight,
- val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
-
- if ( extra === "border" ) {
- return val;
+ cur = curCSS(elem, name),
+ // We're addressing the way Firefox handles certain inputs and buttons, offsetWidth/height actually returns a normal width/height
+ ff = /input|button/i.test( elem.tagName.toLowerCase() ) && curCSS( elem, '-moz-box-sizing' ) === 'border-box';
+
+ // IE will return auto if we try to grab a width/height that is not set
+ if( ff || cur === 'auto') {
+ cur = name === "width" ? elem.offsetWidth : elem.offsetHeight;
}
-
- jQuery.each( which, function() {
- if ( !extra ) {
- val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
- }
-
- if ( extra === "margin" ) {
- val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
-
- } else {
- val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
+
+ // Fixes an IE7 effects test. "Chain show hide" was returning "scroll" instead of "visible"
+ if( name == "height" ){
+ elem.offsetHeight;
+ }
+
+ var val = parseFloat(cur) || 0;
+
+ if ( extra ) {
+ for( var i = 0, len = which.length; i < len ; i++ ) {
+ var dir = which[i];
+ // outerWidth/height
+ if ( extra === "border" || extra === 'margin' ) {
+ val += parseFloat(jQuery.css( elem, "border" + dir + "Width" )) || 0;
+ val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0;
+ if( extra == 'margin' ) {
+ val += parseFloat(jQuery.css( elem, "margin" + dir )) || 0;
+ }
+ }
+ // innerWidth/height
+ else {
+ val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0;
+ }
}
- });
-
+ }
return val;
}