Re: [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)

For webcomponents, I was just experimenting with @justinfagnani post, and it seems to work properly even if we remove <code>Object.setPrototypeOf(MyEl, HTMLElement);</code>.

I am aware that for some reason, DOM constructor's __proto__ points to its prototype's constructor instead of Function.prototype, for instance:

<code>
HTMLElement.__proto__ === Element //true
Element.__proto__ === Node  //also true
</code>

Normally, I would expect a constructor's __proto__ to point to Function.prototype, so I "presume" @justinfagnani used <code>Object.setPrototypeOf(MyEl, HTMLElement);</code> for consistency in the way the Browser laid out their inheritence. 

Question is this:
> Apart from "static" properties not being inherited (such as <code>Element._someStaticProperty === MyEl._someStaticProperty</code>) by the custom element, is there any side effect of removing <code>Object.setPrototypeOf(MyEl, HTMLElement);</code> all together?

-- 
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#issuecomment-427558574

Received on Saturday, 6 October 2018 09:06:53 UTC