Skip to content

Commit

Permalink
updateStyle(): use setProperty() when css vars and dashed-properties, f…
Browse files Browse the repository at this point in the history
  • Loading branch information
kfule authored and dead-claudia committed Nov 18, 2024
1 parent f3977b3 commit abcbacc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ module.exports = function() {
for (var key in style) {
var value = style[key]
if (value != null) {
if (key[0] === "-" && key[1] === "-") element.style.setProperty(key, String(value))
if (key.includes("-")) element.style.setProperty(key, String(value))
else element.style[key] = String(value)
}
}
Expand All @@ -804,14 +804,14 @@ module.exports = function() {
for (var key in style) {
var value = style[key]
if (value != null && (value = String(value)) !== String(old[key])) {
if (key[0] === "-" && key[1] === "-") element.style.setProperty(key, value)
if (key.includes("-")) element.style.setProperty(key, value)
else element.style[key] = value
}
}
// Remove style properties that no longer exist
for (var key in old) {
if (old[key] != null && style[key] == null) {
if (key[0] === "-" && key[1] === "-") element.style.removeProperty(key)
if (key.includes("-")) element.style.removeProperty(key)
else element.style[key] = ""
}
}
Expand Down

0 comments on commit abcbacc

Please sign in to comment.