Re: [w3c/webcomponents] The is="" attribute is confusing? Maybe we should encourage only ES6 class-based extension. (#509)

@rniwa 

> FWIW, we're against subclassing subclasses of HTMLElement (e.g. HTMLInputElement, etc...) for various reasons, so WebKit isn't going to support this feature anyway. Extension of builtin elements are much better served with mixins.

I think subclassing if fine, but just that the `{extends:___}` arg for `customElements.define` and `is=""` are the wrong tool for it, based on why they are confusing in my OP. But, I still believe subclassing can generally be useful in various cases, and that it should just be as easy as normal inheritance.

To summarize, it'd be better to define inheritance with one step (rather than the current 3 steps), and I'll update the OP to make this more clear up front:

### Current way, inheritance has to be specified three times: 

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

### better way, inheritance specified once, much easier:

```
class MyButton extends HTMLButtonElement {} // 1st and only time
customElements.define('my-button', MyButton)
<my-button></my-button>
```

### mixins

But @rniwa, you mentioned mixins, which I think are a new topic that can solve many needs completely aside from inheritance (which otherwise `is=""` here would solve). Do you mind commenting on #727 about what you like/dislike of my "element behaviors" and `has=""` attribute implementation, and we can go from there?

-- 
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-364689786

Received on Saturday, 10 February 2018 20:34:25 UTC