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

add support for nested shadow dom #834

Merged
merged 12 commits into from
Mar 18, 2022
Merged

add support for nested shadow dom #834

merged 12 commits into from
Mar 18, 2022

Conversation

YunFeng0817
Copy link
Member

@YunFeng0817 YunFeng0817 commented Feb 16, 2022

scenario

If a page highly depends on custom elements, there may be lots of nested shadow dom. #754 may as an example
And the current version doesn't support recording shadow doms which were attached after the full snapshot.

what changed

  1. Hijack HTMLElement.attachShadow. When we attach a shadow dom on a created element, the old version can't detect the change and the new shadow dom can't be observed.
  2. If we attach a shadow dom on a created element, the serialized element data won't contain 'isShadowHost' property. So I have to add a workaround on the replay side.
  3. notInDoc check doesn't work for nested shadow dom so I changed the checking way.
  4. add recording test for nested shadow dom

Related issues: #38, #754

@YunFeng0817 YunFeng0817 marked this pull request as draft March 9, 2022 13:17
@YunFeng0817 YunFeng0817 marked this pull request as ready for review March 9, 2022 16:47
Copy link
Contributor

@Juice10 Juice10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm new to shadowDom, so probably not the best to judge this, but the PR looks good to me!

packages/rrweb/src/record/shadow-dom-manager.ts Outdated Show resolved Hide resolved
packages/rrweb/src/record/shadow-dom-manager.ts Outdated Show resolved Hide resolved
@Yuyz0112
Copy link
Member

Looks this is the only way to observe the attaching behavior.

@Yuyz0112 Yuyz0112 merged commit d8f9290 into master Mar 18, 2022
@YunFeng0817 YunFeng0817 deleted the shadowdom branch March 18, 2022 09:04
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.

None yet

3 participants