Catch WrongDocumentError thrown by compareBoundaryPoints (#491)

* Catch WrongDocumentError thrown by compareBoundaryPoints

* Filter error based on name
This commit is contained in:
toasted-nutbread 2020-05-02 12:59:59 -04:00 committed by GitHub
parent efa7a5ecc3
commit 51032d1eca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,7 +94,15 @@ class TextSourceRange {
this.rangeStartOffset === other.rangeStartOffset this.rangeStartOffset === other.rangeStartOffset
); );
} else { } 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;
}
} }
} }