diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-01-17 20:47:51 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-01-17 20:47:51 -0500 |
commit | d8b0d5267b93e46e69c89e3b8abcc660d2712b46 (patch) | |
tree | 86e6d7fa9b0a4303d3b4580be2eeb1defb702394 /ext/fg | |
parent | 4c3321612b2aee9860118f04a2222d3ad07ca2ce (diff) |
Catch exception on range.setStart
Fixes #328
Diffstat (limited to 'ext/fg')
-rw-r--r-- | ext/fg/js/document.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index e068e3ba..db9f0cdc 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -269,8 +269,14 @@ const caretRangeFromPoint = (() => { const range = document.createRange(); const offset = (node.nodeType === Node.TEXT_NODE ? position.offset : 0); - range.setStart(node, offset); - range.setEnd(node, offset); + try { + range.setStart(node, offset); + range.setEnd(node, offset); + } catch (e) { + // Firefox throws new DOMException("The operation is insecure.") + // when trying to select a node from within a ShadowRoot. + return null; + } return range; }; } |