W3C home > Mailing lists > Public > public-css-archive@w3.org > February 2018

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

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Sat, 24 Feb 2018 23:30:38 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-368268803-1519515037-sysbot+gh@w3.org>
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.

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

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:24 UTC