[scoped-registries] What does `new` mean for elements in multiple registries?
keithamus opened this issue · comments
This was originally raised by @matthewp:
class MyElement extends HTMLElement {}
customRegistry.define('my-element', MyElement);
new MyElement();
I can't see how the discussion concluded this point. Are elements allowed on multiple registries? What happens with the following?
class MyElement extends HTMLElement {}
customElements.define('my-element', MyElement);
customRegistry1.define('my-element', MyElement);
customRegistry2.define('my-element', MyElement);
new MyElement();
The same constructor is allowed on multiple registries. However, a direct constructor call will only look up the global registry, because otherwise it has no way to know which registry to use.
Yeah, this is spelled out, and was decided on at the Tokyo F2F (I think?).
The main requirement is that new MyElement()
has the same behavior with and without the presence of scoped registries - we can't break existing code. So there's only one right answer: it succeeds if the element is registered in the global registry, and fails if it isn't.
I’ll close this out as it has an answer now. Thanks both!