Skip to content

Commit

Permalink
updateStyle(): use includes() instead of indexOf()
Browse files Browse the repository at this point in the history
  • Loading branch information
kfule committed Nov 4, 2024
1 parent 9bb0d98 commit 9a36904
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.indexOf("-") > -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.indexOf("-") > -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.indexOf("-") > -1) element.style.removeProperty(key)
if (key.includes("-")) element.style.removeProperty(key)
else element.style[key] = ""
}
}
Expand Down

0 comments on commit 9a36904

Please sign in to comment.