From d8b0d5267b93e46e69c89e3b8abcc660d2712b46 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 17 Jan 2020 20:47:51 -0500 Subject: [PATCH] Catch exception on range.setStart Fixes #328 --- ext/fg/js/document.js | 10 ++++++++-- 1 file 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; }; }