question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stop doing data-*, aria-*, start using dataSet

See original GitHub issue

The 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:open
  • Created 10 years ago
  • Reactions:53
  • Comments:28 (13 by maintainers)

github_iconTop GitHub Comments

56reactions
gaearoncommented, May 29, 2015

People rarely use data-* in react now, maybe?

I’ve written a ton of React code this year and I don’t remember ever using it. Maybe no point making it easier.

21reactions
chengloucommented, Jan 10, 2017

@aditya2272sharma We were discussing on making working with data-* and aria-* better (just like we did with style), not eliminating them…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found