aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-17 20:47:51 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-17 20:47:51 -0500
commitd8b0d5267b93e46e69c89e3b8abcc660d2712b46 (patch)
tree86e6d7fa9b0a4303d3b4580be2eeb1defb702394
parent4c3321612b2aee9860118f04a2222d3ad07ca2ce (diff)
Catch exception on range.setStart
Fixes #328
-rw-r--r--ext/fg/js/document.js10
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;
};
}