[w3c/webcomponents] Consider simpler alternative to the "type extension elements" (#478)

The concept currently known as **type extension elements** is rather complicated. Could it be replaced with something simpler that relies on composition rather than inheritance?

I would just define a simple extension mechanism that allows authors to augment elements. For example, first define the extension:

  ```js
  class MaterialButtonExtension {
    constructor(button) {
      this._button = button;
      this._shadowRoot = this._button.attachShadowRoot();
      this._shadowRoot.addEventListener("pointerdown", () => ...);
    }
  }

  document.defineElementExtension("material-button", MaterialButtonExtension);
  ```

Then use it:

  ```html
  <button extension="material-button"></button>
  ```

Major differences from the current approach:

1. No lifcycle callbacks - extension constructor is always called after the element has been fully setup.
2. Extension can be added to standard elements, as well as to the custom elements.
3. Extension is not bound to any specific element name or class (though it's name might suggest that it is intended to work only with e.g. buttons)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/478

Received on Saturday, 2 April 2016 12:59:38 UTC