-
Notifications
You must be signed in to change notification settings - Fork 43
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
✨ Shadow DOM serialisation support #1165
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
6cb6877
to
4b90012
Compare
005e286
to
5f72303
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
we require document interface to in further steps, and originally document.cloneNode returned document object instead of fragment
Confirmed:
Thank you, team ! |
Thanks again @itsjwala and @samarsault for your work. I hope it brings additional value to all your customers! By the way, Safari announced recently that their technical preview has enabled declarative shadow DOM APIs by default. I'm not sure if this includes the |
@mmun yes we're keeping an eye on this development for Safari, though it would be particularly be helpful for browsers in infrastructure (we only support For now, declarative shadow DOM polyfill - ref is working for |
Shadow DOM is a critical part of the newer Web Component standard which is growing in adoption day by day. This shadow DOM is not captured in a Percy snapshot by our existing serialization methods. Hence, this PR adds support for capturing it.
Constraints
We can’t serialize the DOM if the shadow root is attached in closed mode since we don’t have access to the HTML that makes up the tree. We need the shadow root to be open.
Making it work across all browsers in the infrastructure.
Shadow DOM capturing only works if the user’s test browser is
Chromium 90+
Implementation details
Below is summarised lifecycle of
percySnapshot
command (explained in detail here)getInnerHTML
(We've not polyfilled this method for Firefox)#shadow-root (open)
are converted into<template shadowRoot="open">
tagsFirefox/Safari
, and thus we need to deserialize this Declarative Shadow DOM back to its original form.