mirror of
https://github.com/webodf/WebODF.git
synced 2026-12-01 16:56:05 +01:00
Fix failing PositionIteratorTests.
This commit is contained in:
@@ -160,18 +160,19 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter,
|
||||
startNode = walker.currentNode,
|
||||
n,
|
||||
text,
|
||||
prevText = false;
|
||||
nextText = false;
|
||||
if (currentPos === 1) {
|
||||
n = walker.lastChild();
|
||||
} else {
|
||||
n = walker.previousSibling();
|
||||
}
|
||||
while (n) {
|
||||
text = n.nodeType === 3;
|
||||
if (!text || !prevText) { // neighboring texts count as 1 position
|
||||
// neighboring texts count as 1 position
|
||||
text = (n.nodeType === 3) ? n : null;
|
||||
if (text === null || text.nextSibling !== nextText) {
|
||||
c += 1;
|
||||
}
|
||||
prevText = text;
|
||||
nextText = text;
|
||||
n = walker.previousSibling();
|
||||
}
|
||||
walker.currentNode = startNode;
|
||||
@@ -243,13 +244,6 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter,
|
||||
} else {
|
||||
currentPos = 0;
|
||||
}
|
||||
// jiggle the position to make sure it is at an allowed offset
|
||||
if (self.nextPosition()) {
|
||||
self.previousPosition();
|
||||
}
|
||||
if (self.previousPosition()) {
|
||||
self.nextPosition();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
|
||||
@@ -216,7 +216,7 @@ core.PositionIteratorTests = function PositionIteratorTests(runner) {
|
||||
}
|
||||
function testPositions(count) {
|
||||
var n = 0, i, it = t.iterator, ok = true;
|
||||
while (it.nextPosition()) {
|
||||
while (it.nextPosition() && n <= count) {
|
||||
t.c1 = it.container();
|
||||
t.o1 = it.offset();
|
||||
it.setPosition(t.c1, t.o1);
|
||||
|
||||
@@ -62,12 +62,14 @@ if (runtime.type() === "BrowserRuntime") {
|
||||
// tests.push(core.CursorTests);
|
||||
// tests.push(gui.XMLEditTests);
|
||||
}
|
||||
/*
|
||||
tests = [];
|
||||
if (runtime.getDOMImplementation() && runtime.parseXML("<a/>").createRange) {
|
||||
// tests.push(core.PositionIteratorTests);
|
||||
// tests.push(gui.SelectionMoverTests);
|
||||
tests.push(core.PositionIteratorTests);
|
||||
tests.push(gui.SelectionMoverTests);
|
||||
tests.push(gui.AvatarTests);
|
||||
}
|
||||
*/
|
||||
var tester = new core.UnitTester();
|
||||
/**
|
||||
* @param {!Array.<Function>} tests
|
||||
|
||||
Reference in New Issue
Block a user