Skip to content

Use dataset API for interacting with data- attrs#1840

Merged
josevalim merged 2 commits into
elixir-lang:mainfrom
jakobsen:dataset-js-api
Jul 16, 2026
Merged

Use dataset API for interacting with data- attrs#1840
josevalim merged 2 commits into
elixir-lang:mainfrom
jakobsen:dataset-js-api

Conversation

@jakobsen

Copy link
Copy Markdown
Contributor

Please consider this PR only a suggestion.

There is no functional difference between

const isRevealed = el.getAttribute("data-revealed");

and

const isRevealed = el.dataset.revealed;

but to me the latter reads a little neater.

Another nice feature is that dataset.multipleWords in JS translates to data-multiple-words in HTML.

Please consider this PR only a suggestion.

There is no functional difference between

```js
const isRevealed = el.getAttribute("data-revealed");
```

and

```js
const isRevealed = el.dataset.revealed;
```

but to me the latter reads a little neater.

Another nice feature is that `dataset.multipleWords` in JS translates to
`data-multiple-words` in HTML.
Comment thread src/pages/learning/index.astro Outdated
@josevalim
josevalim merged commit 68c3aad into elixir-lang:main Jul 16, 2026
1 check failed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants