Skip to content

Commit 6e4b571

Browse files
authored
Use try/catch instead of checking if element is registered
1 parent a8fb3ba commit 6e4b571

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/register.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ export function register(classObject: CustomElement): void {
1212
.replace(/([A-Z]($|[a-z]))/g, '-$1')
1313
.replace(/(^-|-Element$)/g, '')
1414
.toLowerCase()
15-
if (!window.customElements.get(name)) {
15+
16+
try {
1617
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1718
// @ts-ignore
1819
window[classObject.name] = classObject
1920
window.customElements.define(name, classObject)
21+
} catch {
22+
// silently ignore
2023
}
2124
}

0 commit comments

Comments
 (0)