Re: [WICG/webcomponents] Proposal: Custom attributes for all elements, enhancements for more complex use cases (Issue #1029)

justinfagnani left a comment (WICG/webcomponents#1029)

> > I'm assuming that the dashes requirement is to avoid clashes with 'official' attributes. This doesn't work, because with reflection, a `read-only` attribute still maps to a `readOnly` property, so you still have the namespace clash.
> 
> I agree and I'm not sure custom attributes should be adding properties to elements. Custom Elements should be free to add the property which can look up the custom attribute node, and the custom attribute should be able to internalise its own reflection rules and expose them (perhaps via a `.value` getter or something) but I think the wiring should still be manual.

I strongly agree here.

I think it would be very dangerous for custom attributes to add properties to the element classes from outside the class. It's a much, much more fragile composition than inheritance at class definition time where humans and tools can at least mostly know what properties the inheritance chain will have. Messing with properties from afar is very likely to lead to name clashes.

I would also be very concerned by the global nature of these modifications: 

```ts
HTMLInputElement.attributeRegistry.define("ac-list", ListAttribute);
MyInput.attributeRegistry.define("ac-list", ListAttribute);
```

This would modify the behavior and possibly public API of every input and MyInput in the entire page. If an element depends on the modified behavior and so patches it in, it can break the rest of the page for which the new API and behavior is an unexpected change. This seems like endorsing monkey-patching and will certainly lead to lots of problems.

I see that Lit's properties are listed as prior art, but I don't think they should be. Lit properties should be part of the class definition (and one day we'll replace them with only decorated class accessors). While they sometimes technically can be created on a class from the outside, this is a misuse of the feature and won't if the class has been registered as an element already (the attribute to property map is only computed once).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1029#issuecomment-3522906737
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/1029/3522906737@github.com>

Received on Wednesday, 12 November 2025 16:54:35 UTC