This commit is contained in:
j3d1 2024-06-06 20:58:27 +02:00
parent 046b23c225
commit 2fdcc19933

View file

@ -42,23 +42,23 @@ export default {
calculateOffset(container, node, offset) { calculateOffset(container, node, offset) {
let position = 0; let position = 0;
let found = false; let found = false;
const walk = (node) => { const walk = (elem) => {
if (node === container) { if (elem === node) {
found = true; found = true;
return; return;
} }
if (node.nodeType === 3) { if (elem.nodeType === 3) {
position += node.length; position += elem.length;
} else { } else {
for (let i = 0; i < node.childNodes.length; i++) { for (let i = 0; i < elem.childNodes.length; i++) {
walk(node.childNodes[i]); walk(elem.childNodes[i]);
if (found) { if (found) {
return; return;
} }
} }
} }
}; };
walk(node); walk(container);
return position + offset; return position + offset;
} }
}, },