-
Notifications
You must be signed in to change notification settings - Fork 52
Serialize scroll location #1965
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
Conversation
packages/dom/src/clone-dom.js
Outdated
|
||
// We apply any element transformations here to avoid another treeWalk | ||
applyElementTransformations(clone); | ||
applyElementTransformations(clone, node); |
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.
change the order of params, it should be node, clone
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.
did the change
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.
Approved with a minor comment
This change broke ~1/4 of our screenshots. I think it at least deserves being mentioned in the release notes (and I'd argue it should not have been released as a patch version as well). |
Preserve scroll location during DOM serialization
Problem
We currently don't preserve scroll positions when serializing DOM elements. This can lead to visual differences when capturing screenshots, as elements that were scrolled in the original page appear at their default scroll position (top/left) in the serialized version.
Solution
This PR introduces scroll state serialization functionality through the
serializeScrollState
function intransform-dom.js
. The function:scrollTop
andscrollLeft
values from original DOM elementsdata-percy-scrolltop
anddata-percy-scrollleft
attributes on cloned elements