diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2011-06-17 17:33:29 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-06-17 17:33:29 -0400 |
commit | 124817e6684086ccf74e509309b73d4b4dd89932 (patch) | |
tree | 98feb94cf972fba50df2844422c8080467123689 | |
parent | d59b0f3e27827d189b8b2595142ec6bbc3941dd9 (diff) | |
download | jquery-124817e6684086ccf74e509309b73d4b4dd89932.tar.gz jquery-124817e6684086ccf74e509309b73d4b4dd89932.zip |
Landing pull request 413. Move border/padding checks to after width validation to avoid unnecessary fallbacks. Fixes #9598.
More Details:
- https://github.com/jquery/jquery/pull/413
- http://bugs.jquery.com/ticket/9300
- http://bugs.jquery.com/ticket/9441
- http://bugs.jquery.com/ticket/9598
-rw-r--r-- | src/css.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/css.js b/src/css.js index c60bcdde0..cb7df9f80 100644 --- a/src/css.js +++ b/src/css.js @@ -315,21 +315,20 @@ function getWH( elem, name, extra ) { var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, which = name === "width" ? cssWidth : cssHeight; - if ( extra !== "margin" && extra !== "border" ) { - jQuery.each( which, function() { - val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; - if ( !extra ) { - val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; - } - }); - } - if ( val > 0 ) { - if ( extra === "margin" ) { + if ( extra !== "border" ) { jQuery.each( which, function() { - val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; + if ( !extra ) { + val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; + } + if ( extra === "margin" ) { + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; + } else { + val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; + } }); } + return val + "px"; } |