diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-05-02 12:59:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 12:59:59 -0400 |
commit | 51032d1eca04820a80f34dfd511a927c55975c1f (patch) | |
tree | bf5598f5746509bb959f2de0e1808660ef799d95 /ext/fg/js/source.js | |
parent | efa7a5ecc3bf6def28c12478fbbcd5fb56f1f63c (diff) |
Catch WrongDocumentError thrown by compareBoundaryPoints (#491)
* Catch WrongDocumentError thrown by compareBoundaryPoints
* Filter error based on name
Diffstat (limited to 'ext/fg/js/source.js')
-rw-r--r-- | ext/fg/js/source.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js index 3d9afe0f..0b21b5cc 100644 --- a/ext/fg/js/source.js +++ b/ext/fg/js/source.js @@ -94,7 +94,15 @@ class TextSourceRange { this.rangeStartOffset === other.rangeStartOffset ); } else { - return this.range.compareBoundaryPoints(Range.START_TO_START, other.range) === 0; + try { + return this.range.compareBoundaryPoints(Range.START_TO_START, other.range) === 0; + } catch (e) { + if (e.name === 'WrongDocumentError') { + // This can happen with shadow DOMs if the ranges are in different documents. + return false; + } + throw e; + } } } |