Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean attributes #629

Merged
merged 1 commit into from Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/index.js
Expand Up @@ -186,7 +186,15 @@ export function app(state, actions, view, container) {
} else {
element.removeEventListener(name, eventListener)
}
} else if (name in element && name !== "list" && name !== "type" && !isSvg) {
} else if (
name in element &&
name !== "list" &&
name !== "type" &&
name !== "draggable" &&
name !== "spellcheck" &&
name !== "translate" &&
!isSvg
) {
element[name] = value == null ? "" : value
} else if (value != null && value !== false) {
element.setAttribute(name, value)
Expand Down
27 changes: 27 additions & 0 deletions test/dom.test.js
Expand Up @@ -652,3 +652,30 @@ testVdomToHtml("events", [
html: `<button id="clicked"></button>`
}
])

testVdomToHtml("boolean attributes", [
{
vdom: (
<main>
<input
checked={true}
spellcheck="true"
autocomplete="on"
translate="yes"
/>
<input
checked={false}
spellcheck="false"
autocomplete="off"
translate="no"
/>
</main>
),
html: `
<main>
<input spellcheck="true" autocomplete="on" translate="yes">
<input spellcheck="false" autocomplete="off" translate="no">
</main>
`
}
])