From 33f7e3375edb8d9ffbe2630007aee77ff214e91c Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Tue, 2 Nov 2010 14:05:18 +0100 Subject: [PATCH] Fix class to run in Rhino. --- webodf/lib/core/PointWalker.js | 14 ++++++++++++-- webodf/tests/core/PointWalkerTests.js | 2 +- webodf/tests/tests.js | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/webodf/lib/core/PointWalker.js b/webodf/lib/core/PointWalker.js index 5414918d..3241059b 100644 --- a/webodf/lib/core/PointWalker.js +++ b/webodf/lib/core/PointWalker.js @@ -47,9 +47,15 @@ core.PointWalker = function PointWalker(node) { } }; this.stepForward = function () { + var len; // if this is a text node, move to the next position in the text if (currentNode.nodeType === currentNode.TEXT_NODE) { - if (pos < currentNode.nodeValue.length) { + if (typeof currentNode.nodeValue.length === "number") { + len = currentNode.nodeValue.length; + } else { + len = currentNode.nodeValue.length(); + } + if (pos < len) { pos += 1; return true; } @@ -99,7 +105,11 @@ core.PointWalker = function PointWalker(node) { currentNode = before; before = null; after = null; - pos = currentNode.nodeValue.length; + if (typeof currentNode.nodeValue.length === "number") { + pos = currentNode.nodeValue.length; + } else { + pos = currentNode.nodeValue.length(); + } } else { after = before; before = before.previousSibling; diff --git a/webodf/tests/core/PointWalkerTests.js b/webodf/tests/core/PointWalkerTests.js index 07eb43c8..959cb64d 100644 --- a/webodf/tests/core/PointWalkerTests.js +++ b/webodf/tests/core/PointWalkerTests.js @@ -73,7 +73,7 @@ core.PointWalkerTests = function PointWalkerTests(runner) { p.appendChild(em); em.appendChild(textnode2); p.appendChild(textnode3); - + checkWalker(textnode1, 7, 7); checkWalker(textnode2, 4, 4); checkWalker(textnode3, 6, 6); diff --git a/webodf/tests/tests.js b/webodf/tests/tests.js index fa994b38..5b23fbdd 100644 --- a/webodf/tests/tests.js +++ b/webodf/tests/tests.js @@ -11,8 +11,8 @@ if (runtime.type() !== "NodeJSRuntime") { } if (runtime.type() === "BrowserRuntime") { - tests.push(core.CursorTests); - tests.push(gui.XMLEditTests); + // tests.push(core.CursorTests); + // tests.push(gui.XMLEditTests); } var tester = new core.UnitTester();