Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS: Don't read styles.position in the width/height cssHook unless necessary #4187

Merged
merged 1 commit into from Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/css.js
Expand Up @@ -358,10 +358,14 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {
set: function( elem, value, extra ) {
var matches,
styles = getStyles( elem ),
scrollBoxSize = support.scrollboxSize() === styles.position,

// Only read styles.position if the test has a chance to fail
// to avoid forcing a reflow.
scrollboxSizeBuggy = !support.scrollboxSize() &&
styles.position === "absolute",

// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
boxSizingNeeded = scrollBoxSize || extra,
boxSizingNeeded = scrollboxSizeBuggy || extra,
isBorderBox = boxSizingNeeded &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
subtract = extra ?
Expand All @@ -376,7 +380,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 && scrollBoxSize ) {
if ( isBorderBox && scrollboxSizeBuggy ) {
subtract -= Math.ceil(
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
parseFloat( styles[ dimension ] ) -
Expand Down
2 changes: 1 addition & 1 deletion src/css/support.js
Expand Up @@ -46,7 +46,7 @@ define( [
// Support: Chrome <=64
// Don't get tricked when zoom affects offsetWidth (gh-4029)
div.style.position = "absolute";
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12 || "absolute";
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;

documentElement.removeChild( container );

Expand Down
2 changes: 1 addition & 1 deletion test/unit/support.js
Expand Up @@ -107,7 +107,7 @@ testIframe(
"pixelPosition": true,
"radioValue": false,
"reliableMarginLeft": true,
"scrollboxSize": "absolute"
"scrollboxSize": false
},
chrome: {
"ajax": true,
Expand Down