From a3f3b34ba41cfcac5ad581d31efd5e40b3ac1995 Mon Sep 17 00:00:00 2001 From: Albin Berglund Date: Sat, 10 Aug 2024 15:32:08 +0200 Subject: [PATCH] improve custom element reg --- libs/core/src/lib/components/layout/layout.ts | 8 +------- libs/core/src/lib/components/panel/panel.ts | 7 ++----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/libs/core/src/lib/components/layout/layout.ts b/libs/core/src/lib/components/layout/layout.ts index 238bcd1..b70eaba 100644 --- a/libs/core/src/lib/components/layout/layout.ts +++ b/libs/core/src/lib/components/layout/layout.ts @@ -337,12 +337,6 @@ export class BergLayoutElement extends WebComponent { } } -try { +if (!customElements.get(BERG_LAYOUT_TAG_NAME)) { customElements.define(BERG_LAYOUT_TAG_NAME, BergLayoutElement); -} catch (e) { - console.warn( - `${BERG_LAYOUT_TAG_NAME} is already defined as a web component.` - ); - - throw e; } diff --git a/libs/core/src/lib/components/panel/panel.ts b/libs/core/src/lib/components/panel/panel.ts index 39be41a..19604eb 100644 --- a/libs/core/src/lib/components/panel/panel.ts +++ b/libs/core/src/lib/components/panel/panel.ts @@ -621,7 +621,7 @@ export class BergPanelElement extends WebComponent {
-
+
`; @@ -641,9 +641,6 @@ export class BergPanelElement extends WebComponent { } } -try { +if (!window.customElements.get(BERG_PANEL_TAG_NAME)) { customElements.define(BERG_PANEL_TAG_NAME, BergPanelElement); -} catch (e) { - console.warn(`${BERG_PANEL_TAG_NAME} is already defined as a web component.`); - throw e; }