@@ -346,7 +346,12 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {
346346 set : function ( elem , value , extra ) {
347347 var matches ,
348348 styles = getStyles ( elem ) ,
349- isBorderBox = jQuery . css ( elem , "boxSizing" , false , styles ) === "border-box" ,
349+ scrollBoxSize = support . scrollboxSize ( ) === styles . position ,
350+
351+ // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
352+ boxSizingNeeded = scrollBoxSize || extra ,
353+ isBorderBox = boxSizingNeeded &&
354+ jQuery . css ( elem , "boxSizing" , false , styles ) === "border-box" ,
350355 subtract = extra && boxModelAdjustment (
351356 elem ,
352357 dimension ,
@@ -357,7 +362,7 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {
357362
358363 // Account for unreliable border-box dimensions by comparing offset* to computed and
359364 // faking a content-box to get border and padding (gh-3699)
360- if ( isBorderBox && support . scrollboxSize ( ) === styles . position ) {
365+ if ( isBorderBox && scrollBoxSize ) {
361366 subtract -= Math . ceil (
362367 elem [ "offset" + dimension [ 0 ] . toUpperCase ( ) + dimension . slice ( 1 ) ] -
363368 parseFloat ( styles [ dimension ] ) -
0 commit comments