Re: [w3ctag/design-reviews] HTML General Review: Custom Elements (#244)

> That was the rationale for W3C HTML to require data-* for now, although developers don't really want those extra 5 characters... 

This is misrepresenting developer concerns a tad. Developers are fine with these 5 extra characters in many cases. When it's a small library with few attributes used in few places, `data-*` is fine. However, with multiple attributes used all over the place, `data-` adds clutter and actually hinders readability, as these repetitive prefixes must be cognitively ignored. Furthermore, when it's many attributes, namespacing of some sort is needed to indicate which attributes belong to the library/framework/language and which don't (e.g. `v-`, `ng-`, `mv-` etc) and prevent clashes. If `data-` is ALSO required, it's not 5 characters any more, it's considerably more than 50% of the length of the attribute! 

Furthermore, often custom elements require the addition of new global attributes or attributes on existing, non-custom elements. For example, imagine `<datalist>` implemented as a custom element. It would require `list` on `<input>`, and if that had to be `data-list`, there would be nothing indicating its relationship to the custom element (unless the custom element was also called `<data-list>`, which would actually be very suitable in this particular case, but this doesn't generalize, whereas the problem does).

The suggestion about requiring a hyphen seems the most reasonable to me: it addresses most of the problem, it's consistent with custom elements, and is consistent with existing practice.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/244#issuecomment-420376652

Received on Tuesday, 11 September 2018 18:37:29 UTC