- Notifications
You must be signed in to change notification settings - Fork20.6k
Dimensions: Add offset prop fallback to FF for unreliable TR dimensions#4808
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( ( | ||
// Fall back to offsetWidth/offsetHeight when value is "auto" | ||
// This happens for inline elements with no explicit setting (gh-3571) | ||
val === "auto" || | ||
timmywil marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
// 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) | ||
Comment on lines +149 to +154 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Back when we had lots of support comment, when code was guarded by one, we usually didn't comment what gets worked around as the support comment above the support test was explaining that anyway. Maybe we can remove this comment in that case here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Although, I see we have a similar comment on | ||
( !support.reliableTrDimensions() && nodeName( elem, "tr" ) ) ) && | ||
// Make sure the element is visible & connected | ||
elem.getClientRects().length ) { | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import document from "../var/document.js"; | ||
import documentElement from "../var/documentElement.js"; | ||
import support from "../var/support.js"; | ||
( function() { | ||
var reliableTrDimensionsVal, | ||
div = document.createElement( "div" ); | ||
// Finish early in limited (non-browser) environments | ||
if ( !div.style ) { | ||
return; | ||
mgol marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
// 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+ | ||
// Only Firefox includes border widths | ||
// in computed dimensions. (gh-4529) | ||
support.reliableTrDimensions = function() { | ||
var table, tr, trStyle; | ||
if ( reliableTrDimensionsVal == null ) { | ||
table = document.createElement( "table" ); | ||
tr = document.createElement( "tr" ); | ||
table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; | ||
tr.style.cssText = "border:1px solid"; | ||
// Support: Chrome 86+ | ||
// Height set through cssText does not get applied. | ||
// Computed height then comes back as 0. | ||
tr.style.height = "1px"; | ||
div.style.height = "9px"; | ||
documentElement | ||
.appendChild( table ) | ||
.appendChild( tr ) | ||
.appendChild( div ); | ||
trStyle = window.getComputedStyle( tr ); | ||
reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + | ||
parseInt( trStyle.borderTopWidth, 10 ) + | ||
parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; | ||
documentElement.removeChild( table ); | ||
} | ||
return reliableTrDimensionsVal; | ||
}; | ||
} )(); | ||
export default support; |