Skip to content

Commit

Permalink
Landing pull request 413. Move border/padding checks to after width v…
Browse files Browse the repository at this point in the history
…alidation to avoid unnecessary fallbacks. Fixes #9598.

More Details:
 - jquery#413
 - http://bugs.jquery.com/ticket/9300
 - http://bugs.jquery.com/ticket/9441
 - http://bugs.jquery.com/ticket/9598
  • Loading branch information
mikesherov authored and timmywil committed Jun 17, 2011
1 parent d59b0f3 commit 124817e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down

0 comments on commit 124817e

Please sign in to comment.