Re: [w3c/webcomponents] Why must the is="" attribute exist? (#509)

I may seem naive, when someone who comes from React tries to learn Custom Elements for the first time (which is more likely to happen than someone learning Custom Elements first due to the mere fact that specs are hard to read compared to things like React docs, unfortunately, because specs are meant for implementers, and the actual usage docs if any are sometimes limited or hard to find), they'll face these weird things like the redundant `is=""` form of extension and [globally-registered custom elements that are not registered on a per-component basis](https://github.com/w3c/webcomponents/issues/488).

This is what classes are for, and in the case of the HTML engine where multiple types of elements may share the same interface (which is probably a partial cause to any current problems) the third argument to `customElements.define` is there to clarify things. The `is=""` attribute is simply redundant and out of place from an outter API perspective (which may matter more than whatever extra implementation complexity there may be) because we already specify the extension in the `define()` call.

I'd take this further and propose that every single built in element should have a single unique associated class, and therefore ES2015 class extension would be the only required form of extension definition.

Just in case, let me point out we must currently specify an extension three whole times. For example, to extend a button:

```js
class MyButton extends HTMLButtonElement {} // 1
customElements.define('my-button', MyButton, { extends: 'button' }) // 2
```
```html
<button is="my-button"></button> <!-- 3 -->
```

That's three times we've needed to specify that we're extending something, just to extend one thing. Doesn't this strike you as a bad idea from an end-user perspective?

It should just be this:

```js
class MyButton extends HTMLButtonElement {} // 1
customElements.define('my-button', MyButton)
```

---
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/509#issuecomment-222812504

Received on Tuesday, 31 May 2016 20:38:14 UTC