Custom attributes for all elements
- Upcoming
- Tentative
- Breakout Sessions
- Upcoming
- Tentative
- Breakout Sessions
Meeting
2023's breakouts had a discussion on alternatives to customized built-ins.
A sketch of a proposal came out around this time: customised attributes. https://github.com/WICG/webcomponents/issues/1029
I'd like to set some time to discuss this idea, the merits, complexities, and discuss whether or not this solves problems for developers without too much complexity for the platform.
Agenda
Chairs:
Keith Cirkel, Lea Verou
Description:
2023's breakouts had a discussion on alternatives to customized built-ins.
A sketch of a proposal came out around this time: customised attributes. https://github.com/WICG/webcomponents/issues/1029
I'd like to set some time to discuss this idea, the merits, complexities, and discuss whether or not this solves problems for developers without too much complexity for the platform.
Goal(s):
Decide if a model for Custom Attributes is viable in the platform, and what a design might look like.
Agenda:
- Can we reasonably enforce that HTML will only standardise attribute names without dashes, and developers can use dashes (modulo
data-*andaria-*); see https://github.com/whatwg/html/issues/2271 - Can we agree that pursuing a series of lifecycle callbacks for when an attribute node is connected, disconnected, and changed would be a useful feature for developers, and something that the major browser vendors would be happy pursuing.
- Do we agree that
class CustomAttr extends Attr {}is a good design choice? This means giving Attr() a constructor, and would begetAttributeNode()etc could now return subclasses ofAttr. It would also meansetAttribute/removeAttribute/toggleAttributewould run these lifecycles, including: looking up the attribute name in some form of registry, & calling into script. Is this okay? - Can Attrs leverage
CEReactionsor would we need some kind of newCAReactions? - Reflection is useful for attributes, could we design a way to bake reflection into custom attribute nodes? E.g.
static reflectedAs = "long"which would change the behaviour ofAttr.prototype.valuefor such custom attributes. - Default values for attributes is useful, can we design something like
static defaultValue = ...? - We would likely need some kind of attribute registry (much like
window.customElements). Doeswindow.customAttributesmake sense? Perhaps we wish to define attributes only for specific elements, such as<button>, how would that work? - Custom Element authors may well wish to scope attributes like they do scoped elements, should we do something similar to
shadowRoot.customElementRegistry? How does this interplay with per-element attributes (see above)? - What powers can we give attributes to alter their
ownerElements? We likely don't want to give access to all ofElementInternalsbut for e.g. attributes might want to provide a minimum accessible role or expose custom states. - Often times attributes are paired or at-least coordinate,
popovertarget/popovertargetaction,command/commandfor,type/value. How can custom attribute authors ergonomically co-operate?
Materials:
Joining Instructions
Instructions are restricted to W3C users . You need to log in to see them.
Export options
Personal Links
Please log in to export this event with all the information you have access to.
Public Links
The following links do not contain any sensitive information and can be shared publicly.