Catch exception on range.setStart

Fixes #328
This commit is contained in:
toasted-nutbread 2020-01-17 20:47:51 -05:00
parent 4c3321612b
commit d8b0d5267b

View File

@ -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;
};
}