From 48f1d012ad5045319d4e492dfbefa39da92817b2 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 15 Jan 2024 06:12:33 -0500 Subject: Add toError utility function (#523) * Add asError utility function * Rename to toError --- ext/js/dom/text-source-range.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/js/dom/text-source-range.js') diff --git a/ext/js/dom/text-source-range.js b/ext/js/dom/text-source-range.js index fd09fdda..7f4db4f2 100644 --- a/ext/js/dom/text-source-range.js +++ b/ext/js/dom/text-source-range.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {toError} from '../core/to-error.js'; import {DocumentUtil} from './document-util.js'; import {DOMTextScanner} from './dom-text-scanner.js'; @@ -228,7 +229,7 @@ export class TextSourceRange { try { return this._range.compareBoundaryPoints(Range.START_TO_START, other.range) === 0; } catch (e) { - if (e instanceof Error && e.name === 'WrongDocumentError') { + if (toError(e).name === 'WrongDocumentError') { // This can happen with shadow DOMs if the ranges are in different documents. return false; } -- cgit v1.2.3