You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for making this library! Super helpful for all things DOM layout.
There's a pesky issue when measuring an element that has display: none. getComputedStyle will return the used values if the element has display: none and the computed values otherwise. What this means is that calling getBox on an element with display: none will result in an error as the used values could be a length (e.g., em, rem, etc.) or a keyword like auto.
Would you be open to making the signature of getBox(el: Element) => ?BoxModel? I thought of just wrapping the method in a try/catch in our codebase but we measure layout a large amount of times and a try/catch block would slow it down a lot.
There's more info on the quirks of getComputedStyle's resolved values here.
If this is something you're open to, I'd happily open a PR.
The text was updated successfully, but these errors were encountered:
That's a possibility. I do wonder if that's the only case and is the "correct" source of truth for something like this. I tried finding an exhaustive list of what would cause this but had no luck finding one. Perhaps more research is required, or a dive into the spec.
If display: none is the only case for this, returning 0 for all values would definitely work, though! As people report other instances of similar issues, support for those could be added.
Hi Alex!
Thanks for making this library! Super helpful for all things DOM layout.
There's a pesky issue when measuring an element that has
display: none
.getComputedStyle
will return the used values if the element hasdisplay: none
and the computed values otherwise. What this means is that callinggetBox
on an element withdisplay: none
will result in an error as the used values could be a length (e.g.,em
,rem
, etc.) or a keyword likeauto
.Would you be open to making the signature of
getBox
(el: Element) => ?BoxModel
? I thought of just wrapping the method in a try/catch in our codebase but we measure layout a large amount of times and a try/catch block would slow it down a lot.There's more info on the quirks of
getComputedStyle
's resolved values here.If this is something you're open to, I'd happily open a PR.
The text was updated successfully, but these errors were encountered: