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

Re: [css-variables] The variable syntax - How about not using var() ?

From: Xidorn Quan <quanxunzhen@gmail.com>
Date: Fri, 25 Dec 2015 17:03:21 +1100
Message-ID: <CAMdq699DYtNC=rSUBSbiD8K-vqbu3QcMVj_dYyAi-bVfaB51NQ@mail.gmail.com>
To: Praveen Puglia <praveenpuglia@gmail.com>
Cc: www-style list <www-style@w3.org>
On Fri, Dec 25, 2015 at 4:41 PM, Praveen Puglia <praveenpuglia@gmail.com> wrote:
> What about not using var() at all?
>
> As far as I can say( and that's not too far ) I don't see a problem in using
> --variableName in RHS and getting it's value evaluated. If it's on L.H.S it
> just assigns whatever is on the R.H.S.
>
> Example -
>
> :root {
>     --primaryColor : blue; /* Assignment/Storage*/
> }
>
> a {
>     color : --primaryColor; /* Evaluation */
> }
>
> Other cases are I think ruled out via this example -
> http://www.w3.org/TR/css-variables/#example-3ab19e31
>
> Would the parsing lead to ambiguous situations? If so, can you please
> provide an example so I can understand it better. Again, I am a noob.

>From the perspective of spec, "--primaryColor" is just an
<ident-token> [1], it doesn't make sense to transform a token when
parsing CSS.

Also it could lead to ambiguous, since there are several properties
accept a <custom-ident> [2] as part of their value [3][4], which, in
theory, could be "--" prefixed. (I even thought we should require
<custom-ident> in author style sheets to be prefixed with "--" so that
we wouldn't ever break the forward compatibility of those properties.)

[1] https://drafts.csswg.org/css-syntax-3/#ident-token-diagram
[2] https://drafts.csswg.org/css-values-3/#custom-idents
[3] https://drafts.csswg.org/css-animations-1/#propdef-animation-name
[4] https://drafts.csswg.org/css-lists-3/#propdef-list-style-type

- Xidorn
Received on Friday, 25 December 2015 06:04:29 UTC

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