[w3c/webcomponents] @trusktr you're not returning the right object from the constructor. You're creating an HTMLElement, then implicitly returning MyEl, which is not an HTMLElement. Regardless of setting the prototype and what `instanceof` says, it doesn't wrap a native element object like HTMLElement does. (#766)

@justinfagnani, your example works as well if we remove the <code>Object.setPrototypeOf(MyEl, HTMLElement);</code>  Why is it necessary anyway?

This works:

```js
function MyEl() {
  return Reflect.construct(HTMLElement,[], this.constructor);
}

MyEl.prototype = Object.create(HTMLElement.prototype);
MyEl.prototype.constructor = MyEl;
Object.setPrototypeOf(MyEl, HTMLElement);

MyEl.prototype.connectedCallback = function() {
  console.log('my-el connected');
};
customElements.define('my-el', MyEl);
document.body.appendChild(document.createElement('my-el'));
```

_Originally posted by @justinfagnani in https://github.com/w3c/webcomponents/issues/587#issuecomment-378684197_

-- 
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/766

Received on Friday, 5 October 2018 16:52:12 UTC