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

var inp = document.createElement('input', {is: 'fancy-input'});


On Mon, Jul 2, 2018 at 5:50 AM Marchenko Alexandr <notifications@github.com>
wrote:

> One more about confusion: how should we create such components dynamically?
>
> e.g. I have a component
>
> 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?
>
> // var inp = document.createElement('fancy-input'); // not working - does not render anythingvar inp = document.createElement('input');// inp.is = 'fancy-input'; // not working// inp.setAttribute('is', 'fancy-input'); // not workingdocument.body.appendChild(inp);
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/w3c/webcomponents/issues/509#issuecomment-401664944>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAFO9cSIA-_O6o7rBpr_h3X2yr2NfYFCks5uCZhtgaJpZM4Iq2sA>
> .
>


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

Received on Monday, 2 July 2018 08:38:10 UTC