Re: [w3c/webcomponents] Better custom event support for custom elements would be great (#546)

I would be nice for convenience, but It's possible to write this behavior once, in a base class, then extend from it or mix it in (f.e. with class-factory mixins).

f.e., I use a `WebComponent` base class mixin that contains custom features, then I use it like this:

```js
class MyElement extends WebComponent(HTMLButtonElement) {
  // ...
}
```

where the `WebComponent` function is a [class-factory style mixin](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes) in order to pass to it the underlying native `HTML*Elment` class that I want to ultimately inherit from.

I'm contemplating splitting my features out into different mixins, f.e.

```js
class MyElement extends ShadowComponent(StyledComponent(CustomEventComponent(HTMLButtonElement))) {
  // ...
}
```

Where for example `ShadowComponent` would give a custom element default shadow root features, `StyledComponent` might provide some pattern for applying a style to the component, and `CustomEventComponent` could provide the features you're asking for here. The benefits of these mixins if you can mix and match what features you need rather than having all the features if you don't need them all.

-- 
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/546#issuecomment-246848987

Received on Tuesday, 13 September 2016 22:41:59 UTC