-
Notifications
You must be signed in to change notification settings - Fork 322
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
perf: remove redundant overflow style manipulation #2678
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably intended for more accurate calculation but it triggers a redraw which makes this function heavy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you say more accurate, what are we "losing" here? only legacy browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In modern browsers, elements can have
overflow
styles likevisible
,hidden
,auto
, orscroll
, which control how content is displayed when it exceeds the container's dimensions. Historically (2017<), and in some edge cases even today, browsers have had quirks in how they calculatescrollWidth
andscrollHeight
whenoverflow
is set tovisible:
overflow: visible
Behavior:overflow
isvisible
, the browser does not clip or restrict content, soscrollWidth
andscrollHeight
might not accurately represent the "overflowing" content dimensions.scrollHeight
orscrollWidth
, leading to unreliable results. For example:scrollHeight
might only reflect the visible portion of the element.scrollHeight
andscrollWidth
lazily or only whenoverflow
was set tohidden
,auto
, orscroll
. As a result, developers often had to temporarily setoverflow
to force the browser to update these values.overflow
property to get consistent values.The approach of temporarily setting
overflow: hidden
is a deliberate attempt to work around these historical inconsistencies. Now, it assumes that these historical quirks do not apply or that theoverflow
property is already managed correctly. In modern browsers, the need for such workarounds has significantly decreased. The major benefit is the dramatic performance improvementThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough