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

Thanks for writing this up so quickly! Some initial thoughts on this proposal only, still need to digest some of the referenced alternatives.

1. This is probably obvious but seems like it often comes up: all the capabilities described here are mostly possible in the platform today via `MutationObserver` and `Object.defineProperties`. Therefore, the goal here needs to be clear and is likely something like making these capabilities (1) more ergonomic, (2) perform better, (3) reliably baked in.

2. Experience with customElements and the scoped registries proposal suggests that scoping is a must and to avoid the pain custom elements has gone through, this feature shouldn't ship without it.

3. Custom Element attribute reflection is indeed annoying, but it's not clear if this feature would be directly applicable. Perhaps instead, there's a lower level seralization/deserialization primitive that could be used here and also with `observedAttributes`.

4. It's important to state clearly that the reason to use attributes is to make the augmented behavior _declaratively configurable_. We (or at least I do) typically think of this as being synonymous with **HTML**, **JSX** is very popular and although it is html-like, it has the ability to set complex non-serializable data directly via properties. This suggests that basic version  should support property setting. Here's a straw proposal: (1) use `has` to install a behavior (e.g. has="foo bar", (2) this makes a property `...DataSet` (e.g. `fooDataSet`) available on the element and configurable via `...-data-X` (e.g. foo-data-mood="happy"). Systems that set properties could then just set a property like e.g. fooDataSet.mood = 'happy'.






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

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

Received on Wednesday, 13 September 2023 21:21:25 UTC