Skip to content

Commit 4979d09

Browse files
authored
rethrow errors unless its specifically about redefining
1 parent 113edda commit 4979d09

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/register.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export function register(classObject: CustomElement): void {
1818
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1919
// @ts-ignore
2020
window[classObject.name] = customElements.get(name)
21-
} catch {
22-
// silently ignore
21+
} catch (e: any) {
22+
// The only reason for window.customElements.define to throw a `NotSupportedError`
23+
// is if the element has already been defined.
24+
if (e instanceof DOMException && e.name === 'NotSupportedError') return
25+
26+
throw e
2327
}
2428
}

0 commit comments

Comments
 (0)