Skip to content

Commit 05d5913

Browse files
committed
[css-variables] Better define that <fallback> can contain commas.
--HG-- extra : rebase_source : 01b802db256ae5479c8b4548d972ba763408b77f
1 parent 84a9a77 commit 05d5913

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

css-variables/Overview.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ <h2 id="using-variables" data-level="3"><span class="secno">3 </span>
398398
which can then be substituted into another property with the <a data-autolink="maybe" class="css">var()</a> function.
399399
The syntax of <a data-autolink="maybe" class="css">var()</a> is:
400400

401-
</p><pre><dfn id="default-var-type">&lt;variable&gt;</dfn> = var( <var>variable-name</var> [, <var>&lt;fallback&gt;</var> ]? )
401+
</p><pre><dfn id="default-var-type">&lt;variable&gt;</dfn> = var( <var>variable-name</var> [, <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a> ]? )
402402
</pre>
403403
<p> A variable can be used in place of any part of a value in any property on an element.
404404
Variables can not be used as
@@ -408,13 +408,21 @@ <h2 id="using-variables" data-level="3"><span class="secno">3 </span>
408408
(Doing so usually produces invalid syntax,
409409
or else a value whose meaning has no connection to the variable.)
410410

411-
</p><p> The <var>&lt;fallback&gt;</var> value is identical to the syntax of a <a data-autolink="link" href="#custom-property">custom property</a> value.
411+
</p><p> The <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a> value is identical to the syntax of a <a data-autolink="link" href="#custom-property">custom property</a> value:
412+
it accepts anything allowed by the core syntax of CSS
413+
(except that, since it's a value in a function rather than a value in a declaration,
414+
some tokens that were allowed in a <a data-autolink="link" href="#custom-property">custom property</a> don't work in a <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a> and vice versa,
415+
because they'd close the function early).
416+
417+
</p><p class="note"> Note: The syntax of <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a>, like that of <a data-autolink="link" href="#custom-property">custom properties</a>, allows commas.
418+
For example, a variable use like <a data-autolink="maybe" class="css">var(foo, red, blue)</a> defines a fallback of <a data-autolink="maybe" class="css">red, blue</a>;
419+
that is, anything between the first comma and the end of the function is considered a <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a> value.
412420

413421
</p><p> If the variable named by the first argument is valid,
414422
the variable's value is substituted as normal.
415423
If the variable is invalid,
416-
and a <var>&lt;fallback&gt;</var> was provided,
417-
the <var>&lt;fallback&gt;</var> is substituted instead.
424+
and a <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a> was provided,
425+
the <a data-autolink="link" class="production"><var>&lt;fallback&gt;</var></a> is substituted instead.
418426
Otherwise, the result of evaluating the <a data-autolink="maybe" class="css">var()</a> function will mean
419427
that the containing declaration is invalid at computed-value time.
420428

css-variables/Overview.src.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ <h2 id='using-variables'>
340340
The syntax of ''var()'' is:
341341

342342
<pre>
343-
<dfn id='default-var-type'>&lt;variable></dfn> = var( <var>variable-name</var> [, <var>&lt;fallback></var> ]? )
343+
<dfn id='default-var-type'>&lt;variable></dfn> = var( <var>variable-name</var> [, <<fallback>> ]? )
344344
</pre>
345345

346346
A variable can be used in place of any part of a value in any property on an element.
@@ -351,13 +351,21 @@ <h2 id='using-variables'>
351351
(Doing so usually produces invalid syntax,
352352
or else a value whose meaning has no connection to the variable.)
353353

354-
The <var>&lt;fallback></var> value is identical to the syntax of a <a>custom property</a> value.
354+
The <<fallback>> value is identical to the syntax of a <a>custom property</a> value:
355+
it accepts anything allowed by the core syntax of CSS
356+
(except that, since it's a value in a function rather than a value in a declaration,
357+
some tokens that were allowed in a <a>custom property</a> don't work in a <<fallback>> and vice versa,
358+
because they'd close the function early).
359+
360+
Note: The syntax of <<fallback>>, like that of <a>custom properties</a>, allows commas.
361+
For example, a variable use like ''var(foo, red, blue)'' defines a fallback of ''red, blue'';
362+
that is, anything between the first comma and the end of the function is considered a <<fallback>> value.
355363

356364
If the variable named by the first argument is valid,
357365
the variable's value is substituted as normal.
358366
If the variable is invalid,
359-
and a <var>&lt;fallback></var> was provided,
360-
the <var>&lt;fallback></var> is substituted instead.
367+
and a <<fallback>> was provided,
368+
the <<fallback>> is substituted instead.
361369
Otherwise, the result of evaluating the ''var()'' function will mean
362370
that the containing declaration is invalid at computed-value time.
363371

0 commit comments

Comments
 (0)