From 9f7540d41b9cd7637170ae96b633971c5212ca43 Mon Sep 17 00:00:00 2001 From: Michael Dellanoce Date: Tue, 31 Oct 2023 10:39:36 -0400 Subject: [PATCH] optimize selection of next addList candidate --- packages/rrweb/src/record/mutation.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/rrweb/src/record/mutation.ts b/packages/rrweb/src/record/mutation.ts index 097d1a8fd5..cdceaf50c1 100644 --- a/packages/rrweb/src/record/mutation.ts +++ b/packages/rrweb/src/record/mutation.ts @@ -425,7 +425,13 @@ export default class MutationBuffer { } break; } - candidate = node.previous; + if (node.value.previousSibling && isNodeInLinkedList(node.value.previousSibling)) { + candidate = node.value.previousSibling.__ln; + } else if (node.value.parentNode && isNodeInLinkedList(node.value.parentNode)) { + candidate = node.value.parentNode.__ln; + } else { + candidate = node.previous; + } addList.removeNode(node.value); pushAdd(node.value); }