Re: [csswg-drafts] [css-variables] Documentation needed on using variables with JavaScript

It's more than just not having camel-casing.

My first instinct would be to use `element.style["--my-var"]`, but that doesn't work either: there are no getter/setters in current browsers.  You need to use `element.style.getPropertyValue("--my-var")` and so on.  Which almost no one uses in JS code on the web, so many developers don't even know those methods exist.

I _assume_ that if you're using [Houdini to register custom properties](https://drafts.css-houdini.org/css-properties-values-api/#calculation-of-computed-values), then the object-notation getters & setters would work.  But there's nothing specifically about that in any spec.

Regardless, I agree that the note in the current spec could be a lot more useful. This is a big stumbling block for devs just starting to experiment with custom properties as variables.

-- 
GitHub Notification of comment by AmeliaBR
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1571#issuecomment-312033700 using your GitHub account

Received on Thursday, 29 June 2017 17:18:26 UTC