diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-02-20 21:47:31 -0500 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-02-20 21:47:31 -0500 | 
| commit | dd52a1c01af117d69c953241fc9380596e7bab20 (patch) | |
| tree | c501d214ca847d29b62ba776e213d0054ecdc8b5 /ext/fg/js | |
| parent | ba972d8547089d8f2c8e19749ee0a0ab93d36233 (diff) | |
Improve handling of null values from caretRangeFromPoint
Diffstat (limited to 'ext/fg/js')
| -rw-r--r-- | ext/fg/js/document.js | 12 | 
1 files changed, 5 insertions, 7 deletions
| diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 73e89d99..13acb036 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -85,20 +85,18 @@ 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; -    let rects; -    try { -        rects = range.getClientRects(); -    } -    catch (e) { -        return; -    } +    const rects = range.getClientRects();      if (rects.length === 0) {          return; |