Fix class to run in Rhino.

This commit is contained in:
Jos van den Oever
2010-11-02 14:05:18 +01:00
parent 1f883ebc4f
commit 33f7e3375e
3 changed files with 15 additions and 5 deletions
+12 -2
View File
@@ -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;
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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();