Skip to content

Commit 52b7ec6

Browse files
committed
fix: PR #887 in 'virtual-dom' branch
1 parent fdfa0c0 commit 52b7ec6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/rrweb/src/replay/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,17 @@ export class Replayer {
14021402
if (parent)
14031403
try {
14041404
parent.removeChild(target as Node & RRNode);
1405+
/**
1406+
* https://github.com/rrweb-io/rrweb/pull/887
1407+
* Remove any virtual style rules for stylesheets if a child text node is removed.
1408+
*/
1409+
if (
1410+
this.usingVirtualDom &&
1411+
target.nodeName === '#text' &&
1412+
parent.nodeName === 'STYLE' &&
1413+
(parent as RRStyleElement).rules?.length > 0
1414+
)
1415+
(parent as RRStyleElement).rules = [];
14051416
} catch (error) {
14061417
if (error instanceof DOMException) {
14071418
this.warn(
@@ -1556,6 +1567,17 @@ export class Replayer {
15561567

15571568
(parent as TNode).appendChild(target as TNode);
15581569
}
1570+
/**
1571+
* https://github.com/rrweb-io/rrweb/pull/887
1572+
* Remove any virtual style rules for stylesheets if a new text node is appended.
1573+
*/
1574+
if (
1575+
this.usingVirtualDom &&
1576+
target.nodeName === '#text' &&
1577+
parent.nodeName === 'STYLE' &&
1578+
(parent as RRStyleElement).rules?.length > 0
1579+
)
1580+
(parent as RRStyleElement).rules = [];
15591581

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

0 commit comments

Comments
 (0)