w3c / strategy

team-strat, on GitHub, working in public. Current state: DRAFT
151 stars 45 forks source link

more elegent alternative to data-* attributes #280

Closed therealadityashankar closed 2 years ago

therealadityashankar commented 2 years ago

So I was wondering if there could be a more "elegant" custom attribute alternative compared to the data-* attribute,

Why?

Because people simply choose to ignore this rule in case attributes look too ugly to them, given that normal attributes work just fine instead of data-*, vuejs does exactly this (context: VueJS can be used via a CDN too)

further, I think that, when making more attributes which use native components, having an easier way to write it would be easier

so for example, recently I was making a XHR web-component library that is supposed to change the native attributes/content of the elements, and obviously, the native element needs a method to indicate that its attribute can be changed

I feel the developer experience of the users of my library could vastly improve with the addition of such a change

Example in consideration

<x-abc>
    <img --change="src:source-zone" src="./somewhere-over-the-rainbow"/>
    <span --change="content:other-source"></span>
</x-abc>

versus

<x-abc>
    <img data-change="src:source-zone" src="./somewhere-over-the-rainbow"/>
    <span data-change="content:other-source"></span>
</x-abc>

consider

Suggested alternatives

CSS style -- prefix, or ? prefix, or something similar

I humbly ask the Web overlords to consider my request ❤️ 🥺

marcoscaceres commented 2 years ago

Hi @therealadityashankar. We appreciate your input, but this repo is for more general W3C admin stuff.

Two options for you however. As the HTML spec is the one that standardizes data-* attributes, I suggest reposting your proposal here: http://github.com/whatwg/html/issues/

Alternatively, you can post it for discussion at the WICG: https://discourse.wicg.io