From: Aleksander Ɓukasz Date: Thu, 23 Jan 2014 08:52:10 +0000 (+0100) Subject: smartxml: fix ranges returned by unwrapContents X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/b232b664e08921b114e383f0fc9802b819c5806b?hp=0ee14b1c718895bbc4034df7f6f35c0eabf06838 smartxml: fix ranges returned by unwrapContents --- diff --git a/src/smartxml/core.js b/src/smartxml/core.js index ae6d20e..a2dd0aa 100644 --- a/src/smartxml/core.js +++ b/src/smartxml/core.js @@ -179,12 +179,12 @@ var elementNodeTransformations = { var prev = this.prev(), next = this.next(), - moveLeftRange, moveRightRange, leftMerged; + shiftRange, leftMerged; if(prev && (prev.nodeType === TEXT_NODE) && (myContents[0].nodeType === TEXT_NODE)) { prev.appendText(myContents[0].getText()); myContents[0].detach(); - moveLeftRange = true; + shiftRange = true; leftMerged = true; } else { leftMerged = false; @@ -195,7 +195,6 @@ var elementNodeTransformations = { if(next && (next.nodeType === TEXT_NODE) && (lastContents.nodeType === TEXT_NODE)) { next.prependText(lastContents.getText()); lastContents.detach(); - moveRightRange = true; } } @@ -207,8 +206,8 @@ var elementNodeTransformations = { this.detach(); return { - element1: parent.contents()[myIdx + (moveLeftRange ? -1 : 0)], - element2: parent.contents()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)] + element1: parent.contents()[myIdx + (shiftRange ? -1 : 0)], + element2: parent.contents()[myIdx + childrenLength-1 + (shiftRange ? -1 : 0)] }; },