From 4fc23022f435e193793f56c09abe46e6bd4814d9 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 28 May 2019 10:01:16 +0200 Subject: [PATCH] remove all non-first-br nodes on new empty line, not just first one nextSibling returned null after calling removeNode, so get the nextSibling first --- src/editor/render.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/editor/render.js b/src/editor/render.js index caea18e3ca..58ef0eaee1 100644 --- a/src/editor/render.js +++ b/src/editor/render.js @@ -61,12 +61,13 @@ export function renderModel(editor, model) { let foundBR = false; let partNode = lineContainer.firstChild; while (partNode) { + const nextNode = partNode.nextSibling; if (!foundBR && partNode.tagName === "BR") { foundBR = true; } else { lineContainer.removeChild(partNode); } - partNode = partNode.nextSibling; + partNode = nextNode; } if (!foundBR) { lineContainer.appendChild(document.createElement("br"));