Fix inline link elements bug (#995)

* fix: bug when inlined link elements

* test: update snapshot for test cases

* apply Justin's review suggestions

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
This commit is contained in:
MF
2022-09-30 16:14:35 +10:00
committed by GitHub
parent 3809060684
commit 55ebce7337
8 changed files with 117 additions and 48 deletions

View File

@@ -389,6 +389,11 @@ export class Mirror implements IMirror<RRNode> {
}
replace(id: number, n: RRNode) {
const oldNode = this.getNode(id);
if (oldNode) {
const meta = this.nodeMetaMap.get(oldNode);
if (meta) this.nodeMetaMap.set(n, meta);
}
this.idNodeMap.set(id, n);
}