aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-08-13 21:30:24 +0530
committerAkshay Nair <phenax5@gmail.com>2023-08-13 21:30:24 +0530
commit6b34847b9d461ae0f595ca3a8f0bcbd1ab6030ab (patch)
tree3375956e65b32fc55ab03aa0c9b9d666af77ed6d /src/index.ts
parent6411d58b48682c65165a1e717a9bf837737887f3 (diff)
downloadcss-everything-6b34847b9d461ae0f595ca3a8f0bcbd1ab6030ab.tar.gz
css-everything-6b34847b9d461ae0f595ca3a8f0bcbd1ab6030ab.zip
feat: adds checkbox that doesn't work in example
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts9
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 }))
}