Re: [css-variables] parse-time error handling in uses of variables

On Wed, Dec 5, 2012 at 11:25 PM, L. David Baron <dbaron@dbaron.org> wrote:
> I recently noticed a relatively major omission in
> http://dev.w3.org/csswg/css-variables/ :  it doesn't say anything
> about the or the error handling for *uses* of variables.
>
> In particular, declarations that use variables in the value are
> preserved for later variable substitution, at which point either the
> variable substitution works or the declaration is invalid at
> computed-value time.
>
> However, the specification doesn't define which declarations get
> preserved until computed value time for this process to happen.
>
> I'd like to propose that this preservation (and the resulting
> cascading) should happen for any declaration (of any property) that:
>  (a) meets all the syntactic requirements for the value of a
>      variable property
>  (b) contains at least one "var(" function token
>  (c) has every "var(" function token followed (through the matching
>      ')' token) by syntax that is a valid var() function in this
>      level of the specification
>
>
> For example, this would mean that:
>   background: red;
>   background: var(undefined-variable);
> would produce a transparent background, as would:
>   background: red;
>   background: var(undefined-variable, bad fallback syntax);
> but that:
>   background: green;
>   background: var(undefined-variable, bad fallback syntax,
>                   third argument not in this level of CSS);
> would produce a green background since the second declaration would
> be thrown out because of point (c).

I'm pretty sure I had text about this, actually.  It must have gotten
lost when I punted parent-var() to the next level.

In any case, I'm in favor.  I'll add a paragraph about this.

(Note that your third example is actually valid - the definition of
<fallback-value> is so broad that it includes DELIM(,) tokens, so the
fallback value is "bad fallback syntax, third argument not in this
level of CSS".)

~TJ

Received on Friday, 7 December 2012 17:11:46 UTC