stash
This commit is contained in:
parent
046b23c225
commit
2fdcc19933
1 changed files with 7 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue