mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-10-24 14:59:51 -04:00
Add tests for EPUB CFI
This commit is contained in:
1 parent
8ca6bd5f29
commit
3ac917c706
5 files changed
+209
-3
No files matched your search
+1
-2
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user