Re: [w3c/webcomponents] Move the check for HTMLElement and its subclass from customElements.define to construction timing (#541)

> Can you also help me understand why this check would be easier to make at construction time, instead of at definition time? In both cases you need to compare a constructor (either C, or new.target) against the list of all constructors.

You don't because during the construction, you can just check that you're constructing yourself.  e.g. let's say you're trying to define a custom element with interface `HTMLInputElement`.  Then your implementation either `HTMLInputElement` doesn't have a constructor or not doesn't.

1. `HTMLInputElement` doesn't have a constructor.  In this case, the attempt to `Construct` the element immediately fails.
2. `HTMLInputElement` has a constructor.  In this case, you can simply check that `new.target` isn't `HTMLInputElement` in the constructor.

In either scenario, you don't have to enumerate the list of all builtin HTML*Element constructors.

-- 
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/541#issuecomment-239651425

Received on Sunday, 14 August 2016 01:55:18 UTC