From d6e7fb6bf0fc4377a102f00f5704cc237e47b5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 31 Oct 2016 10:43:27 +0100 Subject: [PATCH] Preserve node reference when splitting --- src/models/node.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/models/node.js b/src/models/node.js index 5e6d601ce..7a7bf00a1 100644 --- a/src/models/node.js +++ b/src/models/node.js @@ -1219,7 +1219,12 @@ const Node = { else { const { nodes } = child - const oneNodes = nodes.takeUntil(n => n.key == one.key).push(one) + + // Try to preserve the nodes list to preserve reference of one == node to avoid re-render + // When spliting at the end of a text node, the first node is preserved + let oneNodes = nodes.takeUntil(n => n.key == one.key) + oneNodes = (oneNodes.size == (nodes.size - 1) && one == nodes.last()) ? nodes : oneNodes.push(one) + const twoNodes = nodes.skipUntil(n => n.key == one.key).rest().unshift(two) one = child.merge({ nodes: oneNodes }) two = child.merge({ nodes: twoNodes, key: uid() })