summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-06-22 21:42:35 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-06-22 21:42:35 -0400
commit542cdb2df9f33cda9c88791d784729af2f7419f6 (patch)
tree13952f62cc005a83e53993680aa9cc43766bd489 /ext/fg/js
parentf77ac32fe1fa762d064e9809ba5439f25f996a6a (diff)
Fix docRangeFromPoint sometimes not returning results
If range.getClientRects() has more than 1 result, it is possible that nothing will be returned even when hovering over a valid target.
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/document.js16
1 files changed, 4 insertions, 12 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index 13acb036..5dcf7b3d 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -97,18 +97,10 @@ function docRangeFromPoint(point) {
if(imposter !== null) imposter.style.zIndex = -2147483646;
const rects = range.getClientRects();
-
- if (rects.length === 0) {
- return;
- }
-
- const rect = rects[0];
- if (point.y > rect.bottom + 2) {
- return;
- }
-
- if (range) {
- return new TextSourceRange(range);
+ for (const rect of rects) {
+ if (point.y <= rect.bottom + 2) {
+ return new TextSourceRange(range);
+ }
}
}