Skip to content

Commit 9833f62

Browse files
committed
[css-variables-1] Specify that if var substitution results in a single CSS-wide keyword, it's processed as if that were the specified value. #5325
1 parent 74a75c2 commit 9833f62

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

css-variables-1/Overview.bs

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -388,29 +388,13 @@ Resolving Dependency Cycles</h3>
388388

389389

390390
<!--
391-
UUUUUUUU UUUUUUUU iiii
392-
U::::::U U::::::U i::::i
393-
U::::::U U::::::U iiii
394-
UU:::::U U:::::UU
395-
U:::::U U:::::U ssssssssss iiiiiiinnnn nnnnnnnn ggggggggg ggggg
396-
U:::::D D:::::U ss::::::::::s i:::::in:::nn::::::::nn g:::::::::ggg::::g
397-
U:::::D D:::::Uss:::::::::::::s i::::in::::::::::::::nn g:::::::::::::::::g
398-
U:::::D D:::::Us::::::ssss:::::s i::::inn:::::::::::::::ng::::::ggggg::::::gg
399-
U:::::D D:::::U s:::::s ssssss i::::i n:::::nnnn:::::ng:::::g g:::::g
400-
U:::::D D:::::U s::::::s i::::i n::::n n::::ng:::::g g:::::g
401-
U:::::D D:::::U s::::::s i::::i n::::n n::::ng:::::g g:::::g
402-
U::::::U U::::::Ussssss s:::::s i::::i n::::n n::::ng::::::g g:::::g
403-
U:::::::UUU:::::::Us:::::ssss::::::si::::::i n::::n n::::ng:::::::ggggg:::::g
404-
UU:::::::::::::UU s::::::::::::::s i::::::i n::::n n::::n g::::::::::::::::g
405-
UU:::::::::UU s:::::::::::ss i::::::i n::::n n::::n gg::::::::::::::g
406-
UUUUUUUUU sssssssssss iiiiiiii nnnnnn nnnnnn gggggggg::::::g
407-
g:::::g
408-
gggggg g:::::g
409-
g:::::gg gg:::::g
410-
g::::::ggg:::::::g
411-
gg:::::::::::::g
412-
ggg::::::ggg
413-
gggggg
391+
██ ██ ███ ████████ ███ ███
392+
██ ██ ██ ██ ██ ██ ██ ██
393+
██ ██ ██ ██ ██ ██ ██ ██
394+
██ ██ ██ ██ ████████ ██ ██
395+
██ ██ █████████ ██ ██ ██ ██
396+
██ ██ ██ ██ ██ ██ ██ ██
397+
███ ██ ██ ██ ██ ███ ███
414398
-->
415399

416400

@@ -568,6 +552,12 @@ Using Cascading Variables: the ''var()'' notation</h2>
568552
does not match its declared grammar,
569553
the declaration is <a>invalid at computed-value time</a>.
570554

555+
If a declaration,
556+
once all ''var()'' functions are substituted in,
557+
contains only a [=CSS-wide keyword=]
558+
(and possibly whitespace),
559+
its value is determined as if that keyword were its [=specified value=] all along.
560+
571561
<div class='example'>
572562
For example,
573563
the following usage is fine from a syntax standpoint,
@@ -589,6 +579,28 @@ Using Cascading Variables: the ''var()'' notation</h2>
589579
rather than the initial value.
590580
</div>
591581

582+
<div class='example'>
583+
While a ''var()'' function can't get a [=CSS-wide keyword=]
584+
from the [=custom property=] itself--
585+
if you tried to specify that,
586+
like ''--foo: initial;'',
587+
it would just trigger [[css-cascade-4#defaulting-keywords|explicit defaulting]]
588+
for the custom property--
589+
it can have a [=CSS-wide keyword=] in its fallback:
590+
591+
<pre>
592+
p { color: var(--does-not-exist, initial); }
593+
</pre>
594+
595+
In the above code, if the ''--does-not-exist'' property didn't exist
596+
or is [=invalid at computed-value time=],
597+
the ''var()'' will instead substitute in the ''initial'' keyword,
598+
making the property behave as if it was originally ''color: initial''.
599+
This will make it take on the document's initial 'color' value,
600+
rather than defaulting to inheritance,
601+
as it would if there were no fallback.
602+
</div>
603+
592604

593605
<h3 id='invalid-variables'>
594606
Invalid Variables</h3>

0 commit comments

Comments
 (0)