Remove children of Document even if doc not in mirror (#923)

* Remove children of Document even if doc not in mirror

* fix flaky test

* Update packages/rrdom/test/diff.test.ts

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>
This commit is contained in:
Justin Halsall
2022-07-01 06:26:24 +02:00
committed by GitHub
parent c81e609d7b
commit a31e272bf2
2 changed files with 19 additions and 1 deletions

View File

@@ -316,7 +316,7 @@ function diffChildren(
* We should delete it before insert a serialized one. Otherwise, an error 'Only one element on document allowed' will be thrown.
*/
if (
replayer.mirror.getMeta(parentNode)?.type === RRNodeType.Document &&
parentNode.nodeName === '#document' &&
replayer.mirror.getMeta(newNode)?.type === RRNodeType.Element &&
(parentNode as Document).documentElement
) {