Skip to content

Commit

Permalink
fix: PR #887 in 'virtual-dom' branch
Browse files Browse the repository at this point in the history
  • Loading branch information
YunFeng0817 committed May 5, 2022
1 parent fdfa0c0 commit 52b7ec6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,17 @@ export class Replayer {
if (parent)
try {
parent.removeChild(target as Node & RRNode);
/**
* https://github.com/rrweb-io/rrweb/pull/887
* Remove any virtual style rules for stylesheets if a child text node is removed.
*/
if (
this.usingVirtualDom &&
target.nodeName === '#text' &&
parent.nodeName === 'STYLE' &&
(parent as RRStyleElement).rules?.length > 0
)
(parent as RRStyleElement).rules = [];
} catch (error) {
if (error instanceof DOMException) {
this.warn(
Expand Down Expand Up @@ -1556,6 +1567,17 @@ export class Replayer {

(parent as TNode).appendChild(target as TNode);
}
/**
* https://github.com/rrweb-io/rrweb/pull/887
* Remove any virtual style rules for stylesheets if a new text node is appended.
*/
if (
this.usingVirtualDom &&
target.nodeName === '#text' &&
parent.nodeName === 'STYLE' &&
(parent as RRStyleElement).rules?.length > 0
)
(parent as RRStyleElement).rules = [];

if (isSerializedIframe(target, this.mirror)) {
const targetId = this.mirror.getId(target as HTMLIFrameElement);
Expand Down

0 comments on commit 52b7ec6

Please sign in to comment.