Skip to content

Commit

Permalink
refix li > span > rangeNode case
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoctint1lvc committed Jun 9, 2024
1 parent 00e95bd commit 4885ab5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
Expand Down
12 changes: 12 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,24 @@ function onMouseMove(mouseMove) {
rangeNode = range.offsetNode;
rangeOffset = range.offset;
}
if (!rangeNode) return;

if (mouseMove.target === savedTarget) {
if (rangeNode === savedRangeNode && rangeOffset === savedRangeOffset) {
return;
}
}

if (rangeNode.parentNode !== mouseMove.target) {
// in case of LI > SPAN > rangeNode, mouseMove target is LI
// we cannot hover the mouse over the SPAN, so try with depth 2, it works in some cases
let edgeCases = rangeNode?.parentNode?.parentNode === mouseMove.target;
if (!edgeCases) {
rangeNode = null;
rangeOffset = -1;
}
}

if (timer) {
clearTimeout(timer);
timer = null;
Expand Down Expand Up @@ -571,6 +582,7 @@ function processSearchResult(result) {
.split("!")[0]
.split(";")[0]
.split(":")[0]
.split(".")[0]
.trim();

let rangeNode = savedRangeNode;
Expand Down

0 comments on commit 4885ab5

Please sign in to comment.