Skip to content

Commit

Permalink
Boolean attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzzy committed Jul 18, 2018
1 parent ebdfc2c commit 23778ee
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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>
`
}
])

0 comments on commit 23778ee

Please sign in to comment.