W3C home > Mailing lists > Public > www-style@w3.org > November 2015

Re: [css-variables] Is making a property negative via `-var(--width)` valid syntax?

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Sun, 8 Nov 2015 16:37:05 -0500
To: Philip Walton <philip@philipwalton.com>, www-style list <www-style@w3.org>
Message-ID: <563FC081.60804@mit.edu>
On 11/8/15 1:51 PM, Philip Walton wrote:
> If I try doing the same thing with custom properties in Firefox is
> fails. I'm assuming that's a bug, but I wanted to ask here to make sure.

The Firefox behavior seems correct to me per spec at first glance, 
though the spec could be clearer about this for sure.  The issue you're 
running into is var() substitutes a sequence of tokens, not a string to 
be retokenized.  This is the part that could be spelled out more clearly.

> .parent {
>    --gutter: 1em;
>    margin: -var(--gutter); /* declaration ignored in FF */

So the value of the custom property in this case is the sequence of 
tokens [1em].

The value of 'margin' is then the sequence of tokens ['-', 1em] which is 
not the same thing as the single token [-1em].

See also example 11 at 
https://drafts.csswg.org/css-variables/#example-3ab19e31 (as of today; I 
wish I could perma-link editor's draft versions), which is pretty much 
exactly your situation, right?

Received on Sunday, 8 November 2015 21:37:38 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:58 UTC