Conversation
|
To prevent future issues with conflicting with native implementations, let's consider offering a version of this that's more of a ponyfill. For example: pony(document).createElement(tag, {customElements})
pony(element).customElements
pony(element).attachShadow({mode: 'open', customElements})This might be fairly annoying in practice and there are some options:
|
| } | ||
|
|
||
| interface ShadowRoot { | ||
| readonly ['customElementRegistry']: CustomElementRegistry | null; |
There was a problem hiding this comment.
It'd be nice for reviewing and future readers to leave links to where public APIs are specced. I think this link would be good here: https://dom.spec.whatwg.org/#dom-documentorshadowroot-customelementregistry
| // > root avoids this. | ||
| const scopeForElement = new WeakMap<Node, Element | ShadowRoot>(); | ||
|
|
||
| const registryForElement = new WeakMap< |
There was a problem hiding this comment.
Maybe choose a more descriptive name or add a comment. Maybe setRegistryForSubtree?
Also, does this implement a spec operation? If so, it'd be useful to have a link.
packages/scoped-custom-element-registry/src/scoped-custom-element-registry.ts
Outdated
Show resolved
Hide resolved
| const {tagName, CustomElementClass} = getTestElement(); | ||
| registry.define(tagName, CustomElementClass); | ||
| shadowRoot.innerHTML = `<${tagName}></${tagName}><div></div>`; | ||
| registry.initialize(shadowRoot); |
There was a problem hiding this comment.
what about initializing a non-shadow root parent, or initializing a subtree where some elements already have registries?
packages/scoped-custom-element-registry/src/scoped-custom-element-registry.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Justin Fagnani <justinfagnani@google.com>
Co-authored-by: Justin Fagnani <justinfagnani@google.com>
Co-authored-by: Justin Fagnani <justinfagnani@google.com>
Co-authored-by: Justin Fagnani <justinfagnani@google.com>
Co-authored-by: Justin Fagnani <justinfagnani@google.com>
* status reported in CustomElementRegistryPolyfill.inUse * support DSD null registries via host attribute `polyfill-shadowrootcustomelementregistry` * add additional tests to address feedback * re-order some tests * tracked scoped context now only supports valid customElementRegistry values * added ability to test native impl on Safari + bail outs for known bugs
Fixes: #603
New proposal: whatwg/html#10854