Skip to content

Commit

Permalink
Constructed stylesheets written out to at global level
Browse files Browse the repository at this point in the history
  • Loading branch information
skitterm committed Sep 24, 2024
1 parent b046610 commit e76afcd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ function slimDOMExcluded(
return false;
}

const constructedStylesheets = {};

export function serializeNodeWithId(
n: Node,
options: {
Expand Down Expand Up @@ -1044,6 +1046,10 @@ export function serializeNodeWithId(
if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
serializedNode.isShadowHost = true;
if (shadowRootEl.adoptedStyleSheets) {
// @ts-expect-error asdf
constructedStylesheets['a'] = shadowRootEl.adoptedStyleSheets.map(
(stylesheet) => stringifyStylesheet(stylesheet),
);
serializedNode.chromaticAdoptedStylesheets =
shadowRootEl.adoptedStyleSheets.map((stylesheet) =>
stringifyStylesheet(stylesheet),
Expand Down Expand Up @@ -1329,7 +1335,8 @@ function snapshot(
: slimDOM === false
? {}
: slimDOM;
return serializeNodeWithId(n, {

const serializedNode = serializeNodeWithId(n, {
doc: n,
mirror,
blockClass,
Expand All @@ -1354,6 +1361,11 @@ function snapshot(
keepIframeSrcFn,
newlyAddedElement: false,
});

// @ts-expect-error asdf
serializedNode.constructedStylesheets = constructedStylesheets;

return serializedNode;
}

export function visitSnapshot(
Expand Down

0 comments on commit e76afcd

Please sign in to comment.