Skip to content
Permalink
Browse files

Dimensions: avoid fetching boxSizing when setting width/height

- this avoids forcing a reflow in some cases

Fixes #3991
  • Loading branch information...
jbedard committed Mar 14, 2018
1 parent 2b5f5d5 commit 73d7e6259c63ac45f42c6593da8c2796c6ce9281
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/css.js
@@ -346,7 +346,12 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {
set: function( elem, value, extra ) {
var matches,
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
scrollBoxSize = support.scrollboxSize() === styles.position,

// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
boxSizingNeeded = scrollBoxSize || extra,
isBorderBox = boxSizingNeeded &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
subtract = extra && boxModelAdjustment(
elem,
dimension,
@@ -357,7 +362,7 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {

// Account for unreliable border-box dimensions by comparing offset* to computed and
// faking a content-box to get border and padding (gh-3699)
if ( isBorderBox && support.scrollboxSize() === styles.position ) {
if ( isBorderBox && scrollBoxSize ) {
subtract -= Math.ceil(
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
parseFloat( styles[ dimension ] ) -

0 comments on commit 73d7e62

Please sign in to comment.
You can’t perform that action at this time.