W3C home > Mailing lists > Public > www-style@w3.org > February 2013

Re: [css-variables] fallback value handling needs better definition

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 27 Feb 2013 11:07:10 -0800
Message-ID: <CAAWBYDBBd3TL_x7hDWYZXGyeeHJR1x680Ka69x5Jh_Ukcogk-Q@mail.gmail.com>
To: John Daggett <jdaggett@mozilla.com>
Cc: www-style list <www-style@w3.org>
On Wed, Feb 27, 2013 at 5:19 AM, John Daggett <jdaggett@mozilla.com> wrote:
> Tab Atkins wrote:
>> > The current ED of CSS Variables defines syntax for a fallback value [1].
>> > It defines the use of the fallback value this way:
>> >
>> >   If the variable named by the first argument is valid, the
>> >   variable's value is substituted as normal. If it's invalid, and
>> >   a <fallback> was provided, the <fallback> is substituted
>> >   instead. Otherwise, the variable is an invalid variable.
>> >
>> > Does this mean that undefined variables cause the <fallback> to be substituted?
>>
>> Other text in that section defines that undefined variables are
>> invalid.  (Or rather, that all variables implicitly have an invalid
>> value unless they're specified otherwise.)
>
> Ok, I see the problem.  The second sentence in the spec quote is
> unclear, the problem is what "If it's invalid" refers to.  You intend
> it to mean "If the variable is invalid.." but I read that as "If the
> variable's value is invalid...".  The last sentence is sort of odd too,
> since the paragraph is really defining the return value of var() that
> uses a variable and not the variable itself.
>
> Simple fix:
>
>   If the variable named by the first argument is valid, the
>   variable's value is substituted as normal. If the variable is
>   invalid, and a <fallback> was provided, the <fallback> is
>   substituted instead. Otherwise, the result of evaluating the
>   var() function will mean that the containing declaration is
>   invalid at computed-value time.

Cool, thanks.  I tried writing it some other ways, but couldn't get it
to come out right, so I just used your text.

> Also, the line above this paragraph reads:
>
>   The <fallback> value is identical to the syntax of a custom property.
>
> I think you mean "custom property *value*" instead of custom property.

Indeed.  Fixed.

> So what is the use case that benefits from having a fallback value,
> since it's basically only a fallback for undefined variables?  Seems
> like unnecessary complexity for level 1.

Nope, quite useful for the theming use-case, where you use some
variables in your component that may or may not be defined by the
final author of the page.

~TJ
Received on Wednesday, 27 February 2013 19:07:57 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:06 GMT