html-element-plus icon indicating copy to clipboard operation
html-element-plus copied to clipboard

Add a static method to define components

Open gingerchew opened this issue 1 year ago • 0 comments

I saw in a post somewhere, and can find it if need be, but it went something like in this pen.

class A {
  static define() {
    /* in the example pen, I derive the name from the class name and a regex but ballers choice */
    window.customElements.define(this.name, this);
  }
}

class E extends A {
  static name = 'my-element-name';
}

E.define();

gingerchew avatar Jan 05 '24 20:01 gingerchew