Skip to content
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

Cannot bind to custom CSS property variables #2400

Closed
zero298 opened this issue Jul 16, 2018 · 1 comment
Closed

Cannot bind to custom CSS property variables #2400

zero298 opened this issue Jul 16, 2018 · 1 comment

Comments

@zero298
Copy link
Contributor

zero298 commented Jul 16, 2018

It seems that you are unable to bind to custom CSS property variables using style bindings. I saw this issue on the Stack Overflow question: Using CSS3 Variables in Knockout Style Binding.

The issue seems to stem from knockout/src/binding/defaultBindings/style.js.

Specificially how the style property is set using Array syntax instead of CSSStyleDeclaration#setProperty.

The custom properties don't seem to be enumerated on the actual Object and instead have to be set through setProperty. I'm not sure if the appropriate action would be to have everything use setProperty or if you should check the styleName for "--", say it is a variable, and only use setProperty for that particular instance.

@brianmhunt
Copy link
Member

I wrote and expect to include a style-map binding for tko that accomplishes this. Css vars are amazing and it’s be a shame not to support them. The ordinary binding could be altered to support them too, by -as mentioned- observing if the first two chars are ‘—‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants