Skip to content

Commit

Permalink
Falsey attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzzy committed Mar 29, 2018
1 parent 538a93e commit c0f3013
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ export function app(state, actions, view, container) {
} else {
element.removeEventListener(name, eventListener)
}
} else if (name in element && name !== "list" && !isSvg) {
} else if (
name in element &&
name !== "list" &&
typeof element[name] !== "boolean" &&
!isSvg
) {
element[name] = value == null ? "" : value
} else if (value != null && value !== false) {
element.setAttribute(name, value)
Expand Down
7 changes: 7 additions & 0 deletions test/dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,10 @@ testVdomToHtml("events", [
html: `<button id="clicked"></button>`
}
])

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

0 comments on commit c0f3013

Please sign in to comment.