Skip to content

Commit

Permalink
apply Justin's review suggestions
Browse files Browse the repository at this point in the history
1. make Mirror's replace function act the same with the original one when there's no existed node to get replaced.
2. when replacing with the link/style elements, keep their existing attributes to prevent potential bugs
  • Loading branch information
YunFeng0817 committed Sep 29, 2022
1 parent 10a750d commit 8aefe2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/rrdom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ export class Mirror implements IMirror<RRNode> {
if (oldNode) {
const meta = this.nodeMetaMap.get(oldNode);
if (meta) this.nodeMetaMap.set(n, meta);
this.idNodeMap.set(id, n);
}
this.idNodeMap.set(id, n);
}

reset() {
Expand Down
5 changes: 4 additions & 1 deletion packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,10 @@ export class Replayer {
const newSn = mirror.getMeta(
target as Node & RRNode,
) as serializedElementNodeWithId;
newSn.attributes = mutation.attributes as attributes;
Object.assign(
newSn.attributes,
mutation.attributes as attributes,
);
const newNode = buildNodeWithSN(newSn, {
doc: target.ownerDocument as Document, // can be Document or RRDocument
mirror: mirror as Mirror,
Expand Down

0 comments on commit 8aefe2b

Please sign in to comment.