diff options
author | Alex Yatskov <alex@foosoft.net> | 2019-04-28 11:47:04 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2019-04-28 11:47:04 -0700 |
commit | 9b00daed07db8d70485f2fee22bb1a9b118aa186 (patch) | |
tree | c8c7e9f90d45be017e881abacdd2c328674bb506 /ext/fg/js/document.js | |
parent | 162f3c3836f83660cbb7f01cc724367216eab3e2 (diff) | |
parent | c7f8d0874a758924802179a44757153bbf18bf7f (diff) |
Merge branch 'master' of https://github.com/FooSoft/yomichan
Diffstat (limited to 'ext/fg/js/document.js')
-rw-r--r-- | ext/fg/js/document.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 9366832e..13acb036 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -85,14 +85,24 @@ function docRangeFromPoint(point) { range.setEnd(position.offsetNode, position.offset); return range; } + return null; }; } const range = document.caretRangeFromPoint(point.x, point.y); + if (range === null) { + return; + } if(imposter !== null) imposter.style.zIndex = -2147483646; - const rect = range.getClientRects()[0]; + const rects = range.getClientRects(); + + if (rects.length === 0) { + return; + } + + const rect = rects[0]; if (point.y > rect.bottom + 2) { return; } |