-
Notifications
You must be signed in to change notification settings - Fork 171
Update to support revamped proposal #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Co-authored-by: Justin Fagnani <[email protected]>
Co-authored-by: Justin Fagnani <[email protected]>
Co-authored-by: Justin Fagnani <[email protected]>
Co-authored-by: Justin Fagnani <[email protected]>
Fixes: #603
New proposal: whatwg/html#10854