diff options
author | Timmy Willison <4timmywil@gmail.com> | 2021-01-11 11:56:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 11:56:08 -0500 |
commit | 3bbbc11111840d6fd5160db13f2c1a9acb05c4c4 (patch) | |
tree | bd7c6a2436fba968e00617478eea9c87dcad472e /src/css.js | |
parent | 8969732518470a7f8e654d5bc5be0b0076cb0b87 (diff) | |
download | jquery-3bbbc11111840d6fd5160db13f2c1a9acb05c4c4.tar.gz jquery-3bbbc11111840d6fd5160db13f2c1a9acb05c4c4.zip |
Dimensions: Add offset prop fallback to FF for unreliable TR dimensions
Firefox incorrectly (or perhaps correctly) includes table borders in computed
dimensions, but they are the only one. Workaround this by testing for it and
falling back to offset properties
Fixes gh-4529
Closes gh-4808
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/css.js b/src/css.js index 126d12a17..c82a08c54 100644 --- a/src/css.js +++ b/src/css.js @@ -12,6 +12,7 @@ import swap from "./css/var/swap.js"; import curCSS from "./css/curCSS.js"; import adjustCSS from "./css/adjustCSS.js"; import finalPropName from "./css/finalPropName.js"; +import support from "./css/support.js"; import "./core/init.js"; import "./core/ready.js"; @@ -134,23 +135,24 @@ function getWidthOrHeight( elem, dimension, extra ) { } - if ( ( isIE && - ( - - // Support: IE 9 - 11+ - // Use offsetWidth/offsetHeight for when box sizing is unreliable. - // In those cases, the computed value can be trusted to be border-box. - isBorderBox || - - // Support: IE 10 - 11+ - // IE misreports `getComputedStyle` of table rows with width/height - // set in CSS while `offset*` properties report correct values. - nodeName( elem, "tr" ) - ) || + if ( ( // Fall back to offsetWidth/offsetHeight when value is "auto" // This happens for inline elements with no explicit setting (gh-3571) - val === "auto" ) && + val === "auto" || + + // Support: IE 9 - 11+ + // Use offsetWidth/offsetHeight for when box sizing is unreliable. + // In those cases, the computed value can be trusted to be border-box. + ( isIE && isBorderBox ) || + + // Support: IE 10 - 11+ + // IE misreports `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Support: Firefox 70+ + // Firefox includes border widths + // in computed dimensions for table rows. (gh-4529) + ( !support.reliableTrDimensions() && nodeName( elem, "tr" ) ) ) && // Make sure the element is visible & connected elem.getClientRects().length ) { |