Stop doing data-*, aria-*, start using dataSet
See original GitHub issueThe DOM already exposes data-*
as dataset
but it’s doing transformation from hyphenated to camelCase. From MDN:
<div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>John Doe
</div>
var el = document.querySelector('#user');
// el.id == 'user'
// el.dataset.id === '1234567890'
// el.dataset.user === 'johndoe'
// el.dataset.dateOfBirth === ''
el.dataset.dateOfBirth = '1960-10-03'; // set the DOB.
// 'someDataAttr' in el.dataset === false
el.dataset.someDataAttr = 'mydata';
// 'someDataAttr' in el.dataset === true
We should just start supporting dataSet
(because camelCase). This will allow a couple things:
- easier reasoning about data attributes (
Object.keys(this.props.dataSet)
) - easier merging (
<div dataSet={merge(this.props.dataSet, {extra: 'value', override: 'value'})} />
) - easier (potentially faster?) updates (just modify
node.dataset
)
We’ll want to do the reverse of what the DOM is doing. eg <div dataSet={{dateOfBirth: 'val', foo: 'bar'}} />
becomes <div data-date-of-birth="val" data-foo="bar"></div>
.
To the best of my knowledge, aria-*
doesn’t have a corresponding API, but we should make it work the same way. I think ariaSet
makes sense.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:53
- Comments:28 (13 by maintainers)
Top Results From Across the Web
FAQ | Aria Data Tools
Yes we do! Here are a few. Everyday Activities Dataset. Your browser does not support the video tag. Eye Tracking Visualization. Your browser...
Read more >A Complete Guide to Data Attributes | CSS-Tricks
Everything you ever wanted to know about data attributes in HTML, CSS, and JavaScript.
Read more >Aria Storage Engine - MariaDB Knowledge Base
The Aria storage engine is compiled in by default from MariaDB 5.1 and it is required to be 'in use' when MariaDB is...
Read more >WAI-ARIA basics - Learn web development | MDN
WAI-ARIA is a technology that can help with such problems by ... Let's start by looking at what WAI-ARIA is, and what it...
Read more >VMware Aria Operations for Applications
Why We're Easy to Use. Correlate data across applications, infrastructure, developer and DevOps tools of your choice with packaged dashboards, metrics, and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve written a ton of React code this year and I don’t remember ever using it. Maybe no point making it easier.
@aditya2272sharma We were discussing on making working with data-* and aria-* better (just like we did with
style
), not eliminating them…