- From: Keith Cirkel <notifications@github.com>
- Date: Mon, 01 Dec 2025 08:54:01 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/1029/3597708609@github.com>
keithamus left a comment (WICG/webcomponents#1029)
I should perhaps make my intent clear about what _I'd_ like to prototype:
- I'd like to initially prototype a design that is rooted in Custom Elements. Essentially whenever a decision needs making, think "what does custom elements do" and do that.
- So in this vein, I'll prototype a `customAttributes` global - just like `customElements`. This would be global and apply to all elements. I don't think binding to specific element sets e.g. `HTMLElement.attributeRegistry.define` would be all that useful, and it would be straightforward to handle this in userland, or do after-the-fact if we found it to be very compelling.
- Additionally Custom Attributes would be scopable to ShadowDOM just like Custom Elements are (again, rooted in the same design), this means `attachShadow({ customAttributeRegistry: new CustomAttributeRegistry() })` would allow for the "micro-frontend" style scoping of attribute registries per shadow-dom.
- I'd like to avoid patching prototypes. I think we could have a "magical" `.custom` property which would be a bit like `.dataset`. So `el.custom.myFoo` would get the `my-foo` attribute node instance. If you wanted to e.g. implement (or polyfill) `my-popover`, you could overwrite patch `HTMLElement.prototype.showPopover()` to forward to `el.custom.myPopover.showPopover()` in your code. Likewise if you want a "reflected attribute" getter/setter that would be for e.g. `get popover() { return this.custom.myPopover.value }`. Is `el.custom.myPopover.showPopover()` very long? Yes. It's not an API I yearn for but I think it balances the right trade-offs of safety & explicitness without being overly burdensome.
Hopefully these choices make sense to folks, and of course these decisions can always be refined over time!
--
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1029#issuecomment-3597708609
You are receiving this because you are subscribed to this thread.
Message ID: <WICG/webcomponents/issues/1029/3597708609@github.com>
Received on Monday, 1 December 2025 16:54:05 UTC