From b3412b1d46d04440a62545528ed73cc67482d368 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Thu, 20 Dec 2018 17:29:03 +0800 Subject: [PATCH] fix resolve missing node when target has both previous and next missing node --- src/replay/index.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index 477308a3..d853ebd6 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -463,13 +463,18 @@ export class Replayer { const { previousId, nextId } = targetMutation; const previousInMap = previousId && map[previousId]; const nextInMap = nextId && map[nextId]; - if (previousInMap || nextInMap) { - const { node, mutation } = (previousInMap || nextInMap) as missingNode; - if (previousInMap) { - parent.insertBefore(node, target); - } else { - parent.insertBefore(node, target.nextSibling); + if (previousInMap) { + const { node, mutation } = previousInMap as missingNode; + parent.insertBefore(node, target); + delete map[mutation.node.id]; + delete this.missingNodeRetryMap[mutation.node.id]; + if (mutation.previousId || mutation.nextId) { + this.resolveMissingNode(map, parent, node as Node, mutation); } + } + if (nextInMap) { + const { node, mutation } = nextInMap as missingNode; + parent.insertBefore(node, target.nextSibling); delete map[mutation.node.id]; delete this.missingNodeRetryMap[mutation.node.id]; if (mutation.previousId || mutation.nextId) {