From cd2acd5f26fa2d7348f8334942e3e24bd1b4e519 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Tue, 7 May 2013 14:00:41 +0000 Subject: [PATCH] Set textNodeIncrease to prev.length in removeCursor even when next is null/not a text node. --- webodf/lib/core/Cursor.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webodf/lib/core/Cursor.js b/webodf/lib/core/Cursor.js index 7900d88e..bcf9b70e 100644 --- a/webodf/lib/core/Cursor.js +++ b/webodf/lib/core/Cursor.js @@ -112,11 +112,12 @@ core.Cursor = function Cursor(selection, document) { runtime.assert(Boolean(cursorNode.parentNode), "cursorNode.parentNode is undefined"); // Merge the left and right textnodes - if ((next && next.nodeType === 3 && next.data.length > 0) - && (prev && prev.nodeType === 3 && prev.data.length > 0)) { - prev.parentNode.removeChild(prev); - next.insertData(0, prev.data); - textNodeIncrease = prev.data.length; + if (prev && prev.nodeType === 3 && prev.length > 0) { + textNodeIncrease = prev.length; + if (next && next.nodeType === 3 && next.length > 0) { + prev.parentNode.removeChild(prev); + next.insertData(0, prev.data); + } } cursorNode.parentNode.removeChild(cursorNode);