Skip to content

Check if component aleady exists when creating custom element? #17

@vsmid

Description

@vsmid

I am not sure if this is something we should be doing at all.
It is ok to report duplicate element. It would also be nice to be able to write something like this without throwing error:

export default ({ }, moduleInfo) =>
  customElement('dokit-provisioning', {
    connectedCallback() {
      this.append(div('Welcome to the Dokit Provisioning'));
    }
  });

Dummy solution

e.g.

export const customElement = (name, provider, type) => {
  if (!customElements.get(name)) {
    const CustomElement = build(provider, type);
    let options = type ? { extends: type().localName } : {};
    customElements.define(name, CustomElement, options);
  }
  return define(name);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions