summaryrefslogtreecommitdiff
path: root/ext/fg/js/document.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-06-26 14:17:52 -0700
committerGitHub <noreply@github.com>2019-06-26 14:17:52 -0700
commit672eb55a20a189d295dc80c93d9932b60a76ad28 (patch)
tree6b3983d75c6204be9e99bd7d8d66277594ffe364 /ext/fg/js/document.js
parent654b059b74fd0307fef8f674a9a6e27660660793 (diff)
parent542cdb2df9f33cda9c88791d784729af2f7419f6 (diff)
Merge pull request #164 from toasted-nutbread/document-range-fix
Fix docRangeFromPoint sometimes not returning results
Diffstat (limited to 'ext/fg/js/document.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);
+ }
}
}