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

One more about confusion: how should we create such components dynamically?

e.g. I have a component

```js
class FancyInput extends HTMLInputElement {
  constructor() {
    super();
    this.addEventListener('click', e => {
      console.log('clicked');
    });
  }
}

customElements.define('fancy-input', FancyInput, { extends: 'input' });
```

So, from now on, anywhere on a page I can do something like `<input is="fancy-input" >` and each click on it will be logged to console.

But how about dynamically created items?

```js
// var inp = document.createElement('fancy-input'); // not working - does not render anything
var inp = document.createElement('input');
// inp.is = 'fancy-input'; // not working
// inp.setAttribute('is', 'fancy-input'); // not working
document.body.appendChild(inp);
```

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

Received on Monday, 2 July 2018 03:50:27 UTC