Add tests for EPUB CFI

This commit is contained in:
John Factotum
2022-10-19 17:03:49 +00:00
committed by GitHub
parent 8ca6bd5f29
commit 3ac917c706
5 changed files with 209 additions and 3 deletions
+1 -2
View File
@@ -244,9 +244,8 @@ const partsToNode = (node, parts) => {
let sum = 0
for (const n of node) {
const { length } = n.nodeValue
if (sum + length > offset) return { node: n, offset: offset - sum }
if (sum + length >= offset) return { node: n, offset: offset - sum }
sum += length
if (n === node[node.length - 1]) return { node: n, offset: length - 1 }
}
}