diff options
author | jeresig <jeresig@gmail.com> | 2011-04-14 15:49:15 -0400 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2011-04-14 15:49:15 -0400 |
commit | 84712bd624a9a4eeaab9ea9c543bba494f2cc3e1 (patch) | |
tree | b559edee3cf3e7edf4e35b9738750a1a87eb31ca /src | |
parent | cdb02d09f1166c5fa2ef12a8b5c5fd110a5f84c3 (diff) | |
download | jquery-84712bd624a9a4eeaab9ea9c543bba494f2cc3e1.tar.gz jquery-84712bd624a9a4eeaab9ea9c543bba494f2cc3e1.zip |
Fix formatting of pull 325. Fixes #4146.
Diffstat (limited to 'src')
-rw-r--r-- | src/css.js | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/css.js b/src/css.js index 02bedf0b5..385c21a07 100644 --- a/src/css.js +++ b/src/css.js @@ -9,6 +9,7 @@ var ralpha = /alpha\([^)]*\)/i, rnum = /^-?\d/, rrelNum = /^[+\-]=/, rrelNumFilter = /[^+\-\.\de]+/g, + rinputbutton = /input|button/i, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssWidth = [ "Left", "Right" ], @@ -338,39 +339,45 @@ curCSS = getComputedStyle || currentStyle; function getWH( elem, name, extra ) { var which = name === "width" ? cssWidth : cssHeight, - 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'; + cur = curCSS( elem, name ), + + // We're addressing the way Firefox handles certain inputs and buttons, + // offsetWidth/height actually returns a normal width/height + boxSizing = rinputbutton.test( elem.nodeName ) && + 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') { + if ( boxSizing || cur === "auto" ) { cur = name === "width" ? elem.offsetWidth : elem.offsetHeight; } - - // Fixes an IE7 effects test. "Chain show hide" was returning "scroll" instead of "visible" - if( name == "height" ){ + + // Make sure that IE7 returns the correct computed value for display + if ( name === "height" ) { elem.offsetHeight; } - var val = parseFloat(cur) || 0; + var val = parseFloat( cur ) || 0; if ( extra ) { - for( var i = 0, len = which.length; i < len ; i++ ) { + for ( var i = 0, len = which.length; i < len ; i++ ) { var dir = which[i]; + // outerWidth/height - if ( extra === "border" || extra === 'margin' ) { + 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' ) { + + if ( extra == "margin" ) { val += parseFloat(jQuery.css( elem, "margin" + dir )) || 0; } - } + // innerWidth/height - else { + } else { val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0; } } } + return val; } |