import { customElement } from 'lit/decorators.js' import type { ClassDescriptor } from '@lit/reactive-element/decorators/base' declare type CustomElementClass = Omit /** * A function that extends the @customElement base decorator * and checks that the element hasn't been created yet * */ export function customElementIfNotExist(tagName: string): Function { return function (target: CustomElementClass | ClassDescriptor): any { const el = customElements.get(tagName) if (el) return undefined return customElement(tagName)(target) } }