-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#666 support css variables #827
Changes from 3 commits
0f08806
eec3951
8a8e685
7273c81
b98bc18
7cbcc0d
db44005
79ca673
d9bca90
b2c742e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,21 @@ export function setAccessor(node, name, old, value, isSvg) { | |
} | ||
if (value && typeof value==='object') { | ||
if (typeof old!=='string') { | ||
for (let i in old) if (!(i in value)) node.style[i] = ''; | ||
for (let i in old) if (!(i in value)) { | ||
if (i.indexOf('--') === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can always use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just re-read the original thread, i was wrong since setProperty() uses CSS case rather than camelCase. poop! one option would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Damn GitHub collapsing comments. Missed this |
||
node.style.removeProperty(i); | ||
} else { | ||
node.style[i] = ''; | ||
} | ||
} | ||
} | ||
for (let i in value) { | ||
node.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i]; | ||
if (i.indexOf('--') === 0) { | ||
node.style.setProperty(i, value[i]); | ||
} | ||
else { | ||
node.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i]; | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Challenge: https://twitter.com/preactjs/status/998981752130588673
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be backwards incompatible. Doesn't work for properties that are defined using camel-casing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PepsRyuu aye, saw this after 🙈 /delete