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

@jakearchibald Great point wrt prop namespacing. Some ideas off the top of my head:
1. A `dataset`-like namespace to hang these off of. Downside is that `this` behaves differently. 
2. A shared prefix, so that they wouldn't clash (e.g. `customFoo`).
3. A set of "reserved" prefixes (e.g. `to`, `as`, `by`, etc.), and anything shorter than N characters that is not a reserved prefix, is assumed to be custom. This is definitely harder for custom attribute authors to wrap their heads around, but produces the nicer end-author API, since most custom attribute namespaces I've seen being only needed to be 1-2 chars long. Basically what @keithamus is proposing.

----

@keithamus I think custom attributes would be quite crippled without props. A big part of this proposal is making attribute-property reflection easier for _both_ custom elements and built-ins. The idea is that many things that people today make components about, are actually traits that would be more suited as a modifier (i.e. an attribute) on _other_ elements, rather than a separate component. See the list of use cases in the OP.

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

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

Received on Monday, 4 November 2024 16:17:28 UTC