Skip to content

Commit

Permalink
Handle numbers in styles (#46)
Browse files Browse the repository at this point in the history
* add failing test for passing numbers in styles
* handle numbers correctly in styles
  • Loading branch information
acstll authored and Jorge Bucaran committed Nov 10, 2017
1 parent b033f20 commit ac45747
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function setElementProp(element, name, value, oldValue) {
if (name === "key") {
} else if (name === "style") {
for (var name in merge(oldValue, (value = value || {}))) {
element.style[name] = value[name] || ""
element.style[name] = value[name] != null ? value[name] : ""
}
} else {
try {
Expand Down
10 changes: 9 additions & 1 deletion test/vdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,18 @@ testTrees("styles", [
node: h("div", { style: { color: "blue", float: "left" } }),
html: `<div style="color: blue; float: left;"></div>`
},
{
node: h("div", { style: { opacity: 1 } }),
html: `<div style="opacity: 1;"></div>`
},
{
node: h("div", { style: { opacity: 0 } }),
html: `<div style="opacity: 0;"></div>`
},
{
node: h("div"),
html: `<div style=""></div>`
}
},
])

testTrees("update element data", [
Expand Down

0 comments on commit ac45747

Please sign in to comment.