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) {
let position = 0;
let found = false;
const walk = (node) => {
if (node === container) {
const walk = (elem) => {
if (elem === node) {
found = true;
return;
}
if (node.nodeType === 3) {
position += node.length;
if (elem.nodeType === 3) {
position += elem.length;
} else {
for (let i = 0; i < node.childNodes.length; i++) {
walk(node.childNodes[i]);
for (let i = 0; i < elem.childNodes.length; i++) {
walk(elem.childNodes[i]);
if (found) {
return;
}
}
}
};
walk(node);
walk(container);
return position + offset;
}
},