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

v1.0.0-beta.1 #23

Merged
merged 5 commits into from
Oct 15, 2023
Merged

v1.0.0-beta.1 #23

merged 5 commits into from
Oct 15, 2023

Conversation

niklasramo
Copy link
Owner

@niklasramo niklasramo commented Oct 13, 2023

Breaking changes

  • Update the document width/height computation logic:
    • Previously we allowed getting the document width/height with or without the viewport scrollbar, which isn't really logical as the viewport scrollbar is not part of the document exactly. So, to amend that, you will now get the same result from getWidth(document) and getHeight(document) no matter which box edge value you provide as the second argument, and that result is the width/height without the viewport scrollbar.
    • Previously we also included the body element's scrollWidth/scrollHeight in the calculations when deciding the max width/height for the document. This stemmed from the fact that while in quirks mode the main scrollbar (queryable via document.scrollingElement) could've been either the body's scrollbar or the documentElement's scrollbar. However, in standards mode, the main scrolling element is always the documentElement, which is why we don't include the body's scrollWidth/scrollHeight anymore when trying to compute the max width and height for the document.
    • The document's width/height can be fractional, but the current method's for querying it (scrollWidth, scrollHeight, clientWidth, clientHeight) only return rounded integers. To make the document width a bit more accurate in some scenarios we now also inlcude the documentElement's getBoundingClientRect().width/height in the calculations, which returns fractional pixel values.
  • Update the logic for computing documentElement scrollbar width/height:
    • Previously we computed the viewport scrollbar height/width for documentElement, but in reality documentElement can't actually have a scrollbar. Check it yourself, the scrollbar of the documentElement is always outside the bounds of documentElement because it's actually the window's scrollbar , so we always return 0 from now on.
  • Change box edge argument name: "scroll" -> "scrollbar":
    • This change affects all methods that accept box edge as an argument. The change was made to prevent any confusion with getting element's scroll width/height vs scrollbar width/height. Now it should be very explicitly conveyed that "scrollbar" width and height includes the element's dimensions up until the end of scrollbar edge, but not including the actual scroll area of the element.
  • Performance optimization for element width/height calculation:
    • In case the element is using "content-box" box sizing we can make the width/height computation a bit faster for the "content" and "padding" box edge cases while sacrificing a bit of precision. In these cases we can just start with window.getComputedStyle(elem).width/height, which's precision varies per browser, but still always returns values with at least 2 decimal precision. In practice you probably won't notice the difference compared to the original approach where we started peeling the layers off of elem.getBoundingClientRect().width/height, but it's still a breaking change compared to the previous behavior.

@niklasramo niklasramo self-assigned this Oct 15, 2023
@niklasramo niklasramo marked this pull request as draft October 15, 2023 19:57
@niklasramo niklasramo marked this pull request as ready for review October 15, 2023 20:10
@niklasramo niklasramo merged commit 932116e into master Oct 15, 2023
1 check passed
@niklasramo niklasramo deleted the beta-1 branch October 15, 2023 20:10
@niklasramo niklasramo changed the title Beta 1 v1.0.0-beta.1 Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant