From 6b34847b9d461ae0f595ca3a8f0bcbd1ab6030ab Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 13 Aug 2023 21:30:24 +0530 Subject: feat: adds checkbox that doesn't work in example --- src/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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 })) } -- cgit v1.3.1