🌐 AI搜索 & 代理 主页
Skip to content

Commit 73d7e62

Browse files
committed
Dimensions: avoid fetching boxSizing when setting width/height
- this avoids forcing a reflow in some cases Fixes #3991
1 parent 2b5f5d5 commit 73d7e62

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/css.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)