mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
CSS: Don't read styles.position in the width/height cssHook unless necessary
Current width/height cssHook reads the computed position style even if not necessary as the browser passes the scrollboxSize support test. That has been changed. This commit also makes the scrollboxSize support test in line with all others (i.e. only return true or false) and changes the variable name in the hook to make the code clearer. Fixes gh-4185 Closes gh-4187
This commit is contained in:
parent
dae5f3ce3d
commit
354f6036f2
10
src/css.js
10
src/css.js
@ -358,10 +358,14 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {
|
|||||||
set: function( elem, value, extra ) {
|
set: function( elem, value, extra ) {
|
||||||
var matches,
|
var matches,
|
||||||
styles = getStyles( elem ),
|
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)
|
// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
|
||||||
boxSizingNeeded = scrollBoxSize || extra,
|
boxSizingNeeded = scrollboxSizeBuggy || extra,
|
||||||
isBorderBox = boxSizingNeeded &&
|
isBorderBox = boxSizingNeeded &&
|
||||||
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
||||||
subtract = extra ?
|
subtract = extra ?
|
||||||
@ -376,7 +380,7 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) {
|
|||||||
|
|
||||||
// Account for unreliable border-box dimensions by comparing offset* to computed and
|
// Account for unreliable border-box dimensions by comparing offset* to computed and
|
||||||
// faking a content-box to get border and padding (gh-3699)
|
// faking a content-box to get border and padding (gh-3699)
|
||||||
if ( isBorderBox && scrollBoxSize ) {
|
if ( isBorderBox && scrollboxSizeBuggy ) {
|
||||||
subtract -= Math.ceil(
|
subtract -= Math.ceil(
|
||||||
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
|
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
|
||||||
parseFloat( styles[ dimension ] ) -
|
parseFloat( styles[ dimension ] ) -
|
||||||
|
@ -46,7 +46,7 @@ define( [
|
|||||||
// Support: Chrome <=64
|
// Support: Chrome <=64
|
||||||
// Don't get tricked when zoom affects offsetWidth (gh-4029)
|
// Don't get tricked when zoom affects offsetWidth (gh-4029)
|
||||||
div.style.position = "absolute";
|
div.style.position = "absolute";
|
||||||
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12 || "absolute";
|
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
|
||||||
|
|
||||||
documentElement.removeChild( container );
|
documentElement.removeChild( container );
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ testIframe(
|
|||||||
"pixelPosition": true,
|
"pixelPosition": true,
|
||||||
"radioValue": false,
|
"radioValue": false,
|
||||||
"reliableMarginLeft": true,
|
"reliableMarginLeft": true,
|
||||||
"scrollboxSize": "absolute"
|
"scrollboxSize": false
|
||||||
},
|
},
|
||||||
chrome: {
|
chrome: {
|
||||||
"ajax": true,
|
"ajax": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user