Skip to content

Commit 124817e

Browse files
mikesherovtimmywil
authored andcommitted
Landing pull request 413. Move border/padding checks to after width validation 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
1 parent d59b0f3 commit 124817e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/css.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,21 +315,20 @@ function getWH( elem, name, extra ) {
315315
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
316316
which = name === "width" ? cssWidth : cssHeight;
317317

318-
if ( extra !== "margin" && extra !== "border" ) {
319-
jQuery.each( which, function() {
320-
val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
321-
if ( !extra ) {
322-
val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
323-
}
324-
});
325-
}
326-
327318
if ( val > 0 ) {
328-
if ( extra === "margin" ) {
319+
if ( extra !== "border" ) {
329320
jQuery.each( which, function() {
330-
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
321+
if ( !extra ) {
322+
val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
323+
}
324+
if ( extra === "margin" ) {
325+
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
326+
} else {
327+
val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
328+
}
331329
});
332330
}
331+
333332
return val + "px";
334333
}
335334

0 commit comments

Comments
 (0)