Re: [csswg-drafts] [cssom] getComputedStyle()[--var] return a resolved value?

But the value of `--var: calc(50vh + 4em)` is only interpreted as a sequence of tokens, it never resolves to a length!

In fact CSS alone can't know that you want to resolve that custom property to a length and not to something else. But the [registerProperty](https://drafts.css-houdini.org/css-properties-values-api/#the-registerproperty-function) Houdini API could be used for that.

Another approach is setting the expression that you want to resolve as a length to some standard property which computes to a length, e.g.

```js
el.style.marginLeft = "calc(50vh + 4em)";
getComputedStyle(el).marginLeft; // 380px
el.style.marginLeft = "";
```



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

Received on Saturday, 24 February 2018 23:30:39 UTC