Skip to content

Commit

Permalink
fix: custom style rules don't get inserted into some iframe elements (#…
Browse files Browse the repository at this point in the history
…823)

* fix: custom style rules don't get inserted into some iframe elements

* code style tweak
  • Loading branch information
YunFeng0817 authored Feb 3, 2022
1 parent c1111ed commit 5ec7d9e
Show file tree
Hide file tree
Showing 4 changed files with 709 additions and 12 deletions.
19 changes: 7 additions & 12 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,6 @@ export class Replayer {
this.newDocumentQueue = this.newDocumentQueue.filter(
(m) => m !== mutationInQueue,
);
if (builtNode.contentDocument) {
const { documentElement, head } = builtNode.contentDocument;
this.insertStyleRules(documentElement, head);
}
}
const { documentElement, head } = this.iframe.contentDocument;
this.insertStyleRules(documentElement, head);
Expand Down Expand Up @@ -726,6 +722,13 @@ export class Replayer {
skipChild: false,
afterAppend: (builtNode) => {
this.collectIframeAndAttachDocument(collected, builtNode);
if (
builtNode.__sn.type === NodeType.Element &&
builtNode.__sn.tagName.toUpperCase() === 'HTML'
) {
const { documentElement, head } = iframeEl.contentDocument!;
this.insertStyleRules(documentElement, head);
}
},
cache: this.cache,
});
Expand All @@ -734,10 +737,6 @@ export class Replayer {
this.newDocumentQueue = this.newDocumentQueue.filter(
(m) => m !== mutationInQueue,
);
if (builtNode.contentDocument) {
const { documentElement, head } = builtNode.contentDocument;
this.insertStyleRules(documentElement, head);
}
}
}

Expand Down Expand Up @@ -1482,10 +1481,6 @@ export class Replayer {
(m) => m !== mutationInQueue,
);
}
if (target.contentDocument) {
const { documentElement, head } = target.contentDocument;
this.insertStyleRules(documentElement, head);
}
}

if (mutation.previousId || mutation.nextId) {
Expand Down
Loading

0 comments on commit 5ec7d9e

Please sign in to comment.