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
2018-11-23 18:08:37 +08:00
parent eab30bd274
commit 86286ddb94

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);