diff options
Diffstat (limited to '')
| -rw-r--r-- | src/index.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/index.ts b/src/index.ts index 765f676..aba1491 100644 --- a/src/index.ts +++ b/src/index.ts @@ -91,11 +91,16 @@ const getEvalActions = ( getVariable: async varName => getPropertyValue($element, varName), updateVariable: async (targetId, varName, value) => { const $el = targetId ? document.getElementById(targetId) : $element + const isCustomProp = varName.startsWith('--') if ($el) { const prevValue = getPropertyValue($el, varName) - ;($el as any).style.setProperty(varName, JSON.stringify(value)) + if (isCustomProp) { + ;($el as any).style.setProperty(varName, JSON.stringify(value)) + } else { + ;($el as any).style[varName] = value + } - if (JSON.stringify(value) !== prevValue) { + if (JSON.stringify(value) !== prevValue && isCustomProp) { const detail = { name: varName, value, prevValue } $el.dispatchEvent(new CustomEvent(CSSX_ON_UPDATE_EVENT, { detail })) } |
