Skip to content

Commit

Permalink
enable to record newly added shadow dom
Browse files Browse the repository at this point in the history
  • Loading branch information
YunFeng0817 committed Feb 7, 2022
1 parent 8b25cc9 commit cf7c0ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ function buildNode(
n.attributes.rr_dataURL
) {
// backup original img srcset
node.setAttribute('rrweb-original-srcset', n.attributes.srcset as string);
node.setAttribute(
'rrweb-original-srcset',
n.attributes.srcset as string,
);
} else {
node.setAttribute(name, value);
}
Expand Down Expand Up @@ -367,7 +370,7 @@ export function buildNodeWithSN(

if (
(n.type === NodeType.Document || n.type === NodeType.Element) &&
!skipChild
(!skipChild || n.isShadowHost)
) {
for (const childN of n.childNodes) {
const childNode = buildNodeWithSN(childN, {
Expand Down
7 changes: 6 additions & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,12 @@ export function serializeNodeWithId(
) {
serializedNode.isShadowHost = true;
for (const childN of Array.from(n.shadowRoot.childNodes)) {
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
const serializedChildNode = serializeNodeWithId(
childN,
Object.assign(bypassOptions, {
skipChild: false,
}),
);
if (serializedChildNode) {
serializedChildNode.isShadow = true;
serializedNode.childNodes.push(serializedChildNode);
Expand Down

0 comments on commit cf7c0ad

Please sign in to comment.