Skip to content

Commit d238191

Browse files
committed
constructed stylesheets in shadow DOM are snapshotted
1 parent 921c6ac commit d238191

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/rrweb-snapshot/src/snapshot.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,10 @@ export function serializeNodeWithId(
10081008
id = genId();
10091009
}
10101010

1011-
const serializedNode = Object.assign(_serializedNode, { id });
1011+
const serializedNode: serializedNode & {
1012+
id: number;
1013+
rrwebAdoptedStylesheets?: Array<string | null>;
1014+
} = Object.assign(_serializedNode, { id });
10121015
// add IGNORED_NODE to mirror to track nextSiblings
10131016
mirror.add(n, serializedNode);
10141017

@@ -1025,8 +1028,15 @@ export function serializeNodeWithId(
10251028
// this property was not needed in replay side
10261029
delete serializedNode.needBlock;
10271030
const shadowRootEl = dom.shadowRoot(n);
1028-
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
1031+
if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
10291032
serializedNode.isShadowHost = true;
1033+
if (shadowRootEl.adoptedStyleSheets.length > 0) {
1034+
serializedNode.rrwebAdoptedStylesheets =
1035+
shadowRootEl.adoptedStyleSheets.map((stylesheet) =>
1036+
stringifyStylesheet(stylesheet),
1037+
);
1038+
}
1039+
}
10301040
}
10311041
if (
10321042
(serializedNode.type === NodeType.Document ||

0 commit comments

Comments
 (0)