Skip to content

Commit ca5dca2

Browse files
author
Jihye Hong
committed
Merge branch 'master' of https://github.com/w3c/csswg-drafts
2 parents da60177 + ccc6c0c commit ca5dca2

File tree

1 file changed

+75
-77
lines changed

1 file changed

+75
-77
lines changed

css-variables-1/Overview.bs

+75-77
Original file line numberDiff line numberDiff line change
@@ -131,60 +131,6 @@ Defining Custom Properties: the '--*' family of properties</h2>
131131
It's expected that the CSS Extensions spec [[CSS-EXTENSIONS]]
132132
will expand on these use-cases and make them easier to do.
133133

134-
<h3 id='syntax'>
135-
Custom Property Value Syntax</h3>
136-
137-
The allowed syntax for <a>custom properties</a> is extremely permissive.
138-
The <<declaration-value>> production matches <em>any</em> sequence of one or more tokens,
139-
so long as the sequence does not contain
140-
<<bad-string-token>>,
141-
<<bad-url-token>>,
142-
unmatched <<)-token>>, <<]-token>>, or <<}-token>>,
143-
or top-level <<semicolon-token>> tokens or <<delim-token>> tokens with a value of "!".
144-
145-
In addition, if the value of a <a>custom property</a> contains a ''var()'' reference,
146-
the ''var()'' reference must be valid according to the specified ''var()'' grammar.
147-
If not, the <a>custom property</a> is invalid and must be ignored.
148-
149-
Note: This definition,
150-
along with the general CSS syntax rules,
151-
implies that a custom property value never includes an unmatched quote or bracket,
152-
and so cannot have any effect on larger syntax constructs,
153-
like the enclosing style rule,
154-
when reserialized.
155-
156-
Note: Custom properties can contain a trailing ''!important'',
157-
but this is automatically removed from the property's value by the CSS parser,
158-
and makes the custom property "important" in the CSS cascade.
159-
In other words, the prohibition on top-level "!" characters
160-
does not prevent ''!important'' from being used,
161-
as the ''!important'' is removed before syntax checking happens.
162-
163-
<div class='example'>
164-
For example, the following is a valid custom property:
165-
166-
<pre>
167-
--foo: if(x > 5) this.width = 10;
168-
</pre>
169-
170-
While this value is obviously useless as a <em>variable</em>,
171-
as it would be invalid in any normal property,
172-
it might be read and acted on by JavaScript.
173-
</div>
174-
175-
The values of custom properties,
176-
and the values of ''var()'' functions substituted into custom properties,
177-
are <em>case-sensitive</em>,
178-
and must be preserved in their original author-given casing.
179-
(Many CSS values are <a>ASCII case-insensitive</a>,
180-
which user agents can take advantage of by "canonicalizing" them into a single casing,
181-
but that isn't allowed for custom properties.)
182-
183-
The initial value of a <a>custom property</a> is an empty value;
184-
that is, nothing at all.
185-
This initial value has a special interaction with the ''var()'' notation,
186-
which is explained in the section defining ''var()''.
187-
188134
Custom properties are ordinary properties,
189135
so they can be declared on any element,
190136
are resolved with the normal inheritance and cascade rules,
@@ -262,6 +208,55 @@ Custom Property Value Syntax</h3>
262208
to make maintaining the translations simpler.
263209
</div>
264210

211+
<h3 id='syntax'>
212+
Custom Property Value Syntax</h3>
213+
214+
The allowed syntax for <a>custom properties</a> is extremely permissive.
215+
The <<declaration-value>> production matches <em>any</em> sequence of one or more tokens,
216+
so long as the sequence does not contain
217+
<<bad-string-token>>,
218+
<<bad-url-token>>,
219+
unmatched <<)-token>>, <<]-token>>, or <<}-token>>,
220+
or top-level <<semicolon-token>> tokens or <<delim-token>> tokens with a value of "!".
221+
222+
In addition, if the value of a <a>custom property</a> contains a ''var()'' reference,
223+
the ''var()'' reference must be valid according to the specified ''var()'' grammar.
224+
If not, the <a>custom property</a> is invalid and must be ignored.
225+
226+
Note: This definition,
227+
along with the general CSS syntax rules,
228+
implies that a custom property value never includes an unmatched quote or bracket,
229+
and so cannot have any effect on larger syntax constructs,
230+
like the enclosing style rule,
231+
when reserialized.
232+
233+
Note: Custom properties can contain a trailing ''!important'',
234+
but this is automatically removed from the property's value by the CSS parser,
235+
and makes the custom property "important" in the CSS cascade.
236+
In other words, the prohibition on top-level "!" characters
237+
does not prevent ''!important'' from being used,
238+
as the ''!important'' is removed before syntax checking happens.
239+
240+
<div class='example'>
241+
For example, the following is a valid custom property:
242+
243+
<pre>
244+
--foo: if(x > 5) this.width = 10;
245+
</pre>
246+
247+
While this value is obviously useless as a <em>variable</em>,
248+
as it would be invalid in any normal property,
249+
it might be read and acted on by JavaScript.
250+
</div>
251+
252+
The values of custom properties,
253+
and the values of ''var()'' functions substituted into custom properties,
254+
are <em>case-sensitive</em>,
255+
and must be preserved in their original author-given casing.
256+
(Many CSS values are <a>ASCII case-insensitive</a>,
257+
which user agents can take advantage of by "canonicalizing" them into a single casing,
258+
but that isn't allowed for custom properties.)
259+
265260
<h3 id='guaranteed-invalid'>
266261
Guaranteed-Invalid Values</h3>
267262

@@ -272,7 +267,7 @@ Guaranteed-Invalid Values</h3>
272267

273268
This value serializes as the empty string,
274269
but actually writing an empty value into a custom property,
275-
like ''--foo: ;'',
270+
like <nobr>''--foo: ;''</nobr>,
276271
is a valid (empty) value,
277272
not the [=guaranteed-invalid value=].
278273
If, for whatever reason,
@@ -337,8 +332,9 @@ Resolving Dependency Cycles</h3>
337332
}
338333
</pre>
339334

340-
Both '--one' and '--two' now compute to their initial value,
341-
rather than lengths.
335+
Both '--one' and '--two' are now [=cyclic at computed-value time=],
336+
and compute to the [=guaranteed-invalid value=]
337+
rather than than lengths.
342338
</div>
343339

344340
It is important to note that
@@ -354,12 +350,14 @@ Resolving Dependency Cycles</h3>
354350
these custom properties are <strong>not</strong> cyclic,
355351
and all define valid variables:
356352

357-
<pre>
358-
&lt;one>&lt;two>&lt;three />&lt;/two>&lt;/one>
359-
one { --foo: 10px; }
360-
two { --bar: calc(var(--foo) + 10px); }
361-
three { --foo: calc(var(--bar) + 10px); }
362-
</pre>
353+
<xmp highlight=markup>
354+
<one><two><three /></two></one>
355+
<style>
356+
one { --foo: 10px; }
357+
two { --bar: calc(var(--foo) + 10px); }
358+
three { --foo: calc(var(--bar) + 10px); }
359+
</style>
360+
</xmp>
363361

364362
The &lt;one> element defines a value for '--foo'.
365363
The &lt;two> element inherits this value,
@@ -441,7 +439,8 @@ Using Cascading Variables: the ''var()'' notation</h2>
441439
The first argument to the function is the name of the <a>custom property</a> to be substituted.
442440
The second argument to the function, if provided,
443441
is a fallback value,
444-
which is used as the substitution value when the referenced <a>custom property</a> is invalid.
442+
which is used as the substitution value when the value of the referenced <a>custom property</a>
443+
is the [=guaranteed-invalid value=].
445444

446445
Note: The syntax of the fallback, like that of <a>custom properties</a>, allows commas.
447446
For example, ''var(--foo, red, blue)'' defines a fallback of ''red, blue'';
@@ -544,7 +543,7 @@ Using Cascading Variables: the ''var()'' notation</h2>
544543
''var()'' functions are <a lt="substitute a var()">substituted</a> at computed-value time.
545544
If a declaration,
546545
once all ''var()'' functions are substituted in,
547-
is invalid,
546+
does not match its declared grammar,
548547
the declaration is <a>invalid at computed-value time</a>.
549548

550549
<div class='example'>
@@ -572,14 +571,14 @@ Using Cascading Variables: the ''var()'' notation</h2>
572571
<h3 id='invalid-variables'>
573572
Invalid Variables</h3>
574573

575-
When a <a>custom property</a> has its initial value,
574+
When a <a>custom property’s</a> value is the [=guaranteed-invalid value=],
576575
''var()'' functions cannot use it for substitution.
577576
Attempting to do so
578577
makes the declaration <a>invalid at computed-value time</a>,
579578
unless a valid fallback is specified.
580579

581580
A declaration can be <dfn export>invalid at computed-value time</dfn>
582-
if it contains a ''var()'' that references a <a>custom property</a> with its initial value,
581+
if it contains a ''var()'' that references a <a>custom property</a> with the [=guaranteed-invalid value=],
583582
as explained above,
584583
or if it uses a valid <a>custom property</a>,
585584
but the property value,
@@ -764,16 +763,15 @@ Changes since the May 6 2014 Last Call Working Draft</h2>
764763
<h2 id="acks">
765764
Acknowledgments</h2>
766765

767-
<p>
768-
Many thanks to several people in the CSS Working Group for keeping the dream of variables alive over the years,
769-
particularly Daniel Glazman and David Hyatt.
770-
Thanks to multiple people on the mailing list for helping contribute to the development of this incarnation of variables,
771-
particularly
772-
Brian Kardell,
773-
David Baron,
774-
François Remy,
775-
Roland Steiner,
776-
and Shane Stephens.
766+
Many thanks to several people in the CSS Working Group for keeping the dream of variables alive over the years,
767+
particularly Daniel Glazman and David Hyatt.
768+
Thanks to multiple people on the mailing list for helping contribute to the development of this incarnation of variables,
769+
particularly
770+
Brian Kardell,
771+
David Baron,
772+
François Remy,
773+
Roland Steiner,
774+
and Shane Stephens.
777775

778776
Privacy and Security Considerations {#priv-sec}
779777
===============================================

0 commit comments

Comments
 (0)