diff --git a/src/index.js b/src/index.js index 8f2ed82ba..57df2ddeb 100644 --- a/src/index.js +++ b/src/index.js @@ -133,8 +133,14 @@ export function app(state, actions, view, container) { function updateAttribute(element, name, value, isSVG, oldValue) { if (name === "key") { } else if (name === "style") { - for (var i in clone(oldValue, value)) { - element[name][i] = value == null || value[i] == null ? "" : value[i] + for (var styleName in clone(oldValue, value)) { + var styleValue = + value == null || value[styleName] == null ? "" : value[styleName] + if (styleName.indexOf("--") === 0) { + element[name].setProperty(styleName, styleValue) + } else { + element[name][styleName] = styleValue + } } } else { if (typeof value === "function" || (name in element && !isSVG)) { diff --git a/test/dom.test.js b/test/dom.test.js index 805eccee5..0f0a233d6 100644 --- a/test/dom.test.js +++ b/test/dom.test.js @@ -605,11 +605,15 @@ testTreeSegue("styles", [ html: `
` }, { - tree: h("div", { style: { color: "red", fontSize: "1em" } }), + tree: h("div", { + style: { color: "red", fontSize: "1em", "--foo": "red" } + }), html: `
` }, { - tree: h("div", { style: { color: "blue", float: "left" } }), + tree: h("div", { + style: { color: "blue", float: "left", "--foo": "blue" } + }), html: `
` }, {