check parentNode when calling insertBefore

When add new nodes, we may use insertBefore API to insert node before
its next sibling. But the sibling may not in the DOM tree at that
moment if it was in the missing node map.
This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 20f27a3822
commit 9ed7e09213

View File

@@ -271,9 +271,13 @@ export class Replayer {
return;
}
if (previous && previous.nextSibling) {
if (
previous &&
previous.nextSibling &&
previous.nextSibling.parentNode
) {
parent.insertBefore(target, previous.nextSibling);
} else if (next) {
} else if (next && next.parentNode) {
parent.insertBefore(target, next);
} else {
parent.appendChild(target);