Skip to content

fix: 🐛 data attributes without value outputting as "true"#2804

Merged
Rich-Harris merged 1 commit intosveltejs:masterfrom
kaisermann:fix/dataset-without-value
May 21, 2019
Merged

fix: 🐛 data attributes without value outputting as "true"#2804
Rich-Harris merged 1 commit intosveltejs:masterfrom
kaisermann:fix/dataset-without-value

Conversation

@kaisermann
Copy link
Copy Markdown
Member

Closes #2803

@Conduitry
Copy link
Copy Markdown
Member

I guess data attributes are always strings? I'm not sure whether it makes sense to distinguish between data-foo and data-foo={true}, nor whether that's even possible with the current AST. If not doing that is good enough for other attributes, it's probably good enough here.

@loilo
Copy link
Copy Markdown

loilo commented May 17, 2019

Data attributes, just like all HTML attributes, are always strings. When having <div data-foo foo></div>, data-foo and foo both equal the empty string. IMO casting them to booleans is fine — it's an established practice and even done in the "official" implementations (e.g. with the checked, selected and disabled DOM properties).

@Rich-Harris Rich-Harris merged commit 931c080 into sveltejs:master May 21, 2019
@kaisermann kaisermann deleted the fix/dataset-without-value branch February 6, 2020 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data attribute without value is assigned the string "true"

4 participants