@@ -83,14 +83,13 @@ allow custom properties to directly impact paint and layout behaviours respectiv
83
83
Registered Custom Properties {#behavior-of-custom-properties}
84
84
=============================================================
85
85
86
- A [=custom property=] can,
87
- with the methods defined in this specification,
88
- become a <dfn>registered custom property</dfn> ,
86
+ A [=custom property=] can become a <dfn>registered custom property</dfn> ,
87
+ making it act more like a UA-defined property:
89
88
giving it a syntax that's checked by the UA,
90
89
an initial value,
91
- and a specific inheritance behavior,
92
- making the [=custom property=]
93
- act more like a UA-defined property .
90
+ and a specific inheritance behavior.
91
+ This can be done by the ''@ property'' rule,
92
+ or the {{registerProperty()}} JS function .
94
93
95
94
A [=custom property=] is considered to be registered for a {{Document}}
96
95
if there is a valid ''@property'' rule
@@ -103,6 +102,30 @@ in the document's {{[[registeredPropertySet]]}} slot
103
102
A [=registered custom property=] acts similarly to an unregistered [=custom property=] ,
104
103
except as defined below.
105
104
105
+ Determining the Registration {#determining-registration}
106
+ --------------------------------------------------------
107
+
108
+ A [=registered custom property=] has a <dfn export local-lt="registration">custom property registration</dfn>
109
+ that contains all the data necessary to treat it like a real property.
110
+ It's a [=struct=] consisting of:
111
+
112
+ * a property name (a [=custom property name string=] )
113
+ * a syntax (a [=syntax string=] )
114
+ * an inherit flag (a [=boolean=] )
115
+ * optionally, an initial value (a [=string=] which successfully [=CSS/parses=] according to the syntax)
116
+
117
+ If the {{Document}} ’s {{[[registeredPropertySet]]}} slot
118
+ [=set/contains=] a record with the [=custom property’s=] name,
119
+ the registration is that record.
120
+
121
+ Otherwise,
122
+ if the {{Document}} ’s active stylesheets contain at least one valid ''@property'' rule
123
+ representing a registration with the [=custom property’s=] name,
124
+ the last such one in document order is the registration.
125
+
126
+ Otherwise there is no registration,
127
+ and the [=custom property=] is <em> not</em> a [=registered custom property=] .
128
+
106
129
Parsing Custom Properties {#parsing-custom-properties}
107
130
------------------------------------------------------
108
131
@@ -164,7 +187,7 @@ Calculation of Computed Values {#calculation-of-computed-values}
164
187
----------------------------------------------------------------
165
188
166
189
The [=computed value=] of a [=registered custom property=]
167
- is determined by the syntax it's registered with .
190
+ is determined by the syntax of its [=registration=] .
168
191
169
192
Note: All properties, regardless of registered syntax,
170
193
accept the [=CSS-wide keywords=] ,
@@ -365,18 +388,12 @@ and [[css-syntax-3#tokenization|tokenizing]] the resulting string.
365
388
The <dfn>@property</dfn> Rule {#at-property-rule}
366
389
=================================================
367
390
368
- The ''@property'' rule provides an alternative way to register a custom property,
391
+ The ''@property'' rule represents a [= custom property registration=]
369
392
directly in a stylesheet
370
393
without having to run any JS.
371
- Valid ''@property'' rules result in a [=register a custom property| registered custom property=] ,
394
+ Valid ''@property'' rules result in a [=registered custom property=] ,
372
395
as if {{registerProperty()}} had been called with equivalent parameters.
373
396
374
- The semantics of registered properties are the same
375
- regardless of the mechanism used to perform the registration.
376
- This means that, once registered,
377
- it does not matter whether the registration originated from {{registerProperty()}} or ''@property'' :
378
- the property has the same behavior either way.
379
-
380
397
The syntax of ''@property'' is:
381
398
382
399
<pre class="prod def" nohighlight>
@@ -385,6 +402,10 @@ The syntax of ''@property'' is:
385
402
}
386
403
</pre>
387
404
405
+ A valid ''@property'' rule represents a [=custom property registration=] ,
406
+ with the property name being the serialization of the <<custom-property-name>>
407
+ in the rule's prelude.
408
+
388
409
''@property'' rules require a 'syntax' and 'inherits' descriptor;
389
410
if either are missing,
390
411
the entire rule is invalid and must be ignored.
@@ -396,7 +417,8 @@ if it's missing, the entire rule is invalid and must be ignored.
396
417
Unknown descriptors are invalid and ignored,
397
418
but do not invalidate the ''@property'' rule.
398
419
399
- If multiple valid ''@property'' rules are defined for the same <<custom-property-name>> ,
420
+ Note: As specified in [[#determining-registration]] ,
421
+ if multiple valid ''@property'' rules are defined for the same <<custom-property-name>> ,
400
422
the last one in stylesheet order "wins".
401
423
A custom property registration from {{registerProperty()|CSS.registerProperty()}}
402
424
further wins over any ''@property'' rules
@@ -405,7 +427,7 @@ for the same <<custom-property-name>>.
405
427
A ''@property'' is invalid if it occurs in a stylesheet inside of a [=shadow tree=] ,
406
428
and must be ignored.
407
429
408
- Note : This might change in the future,
430
+ Issue(939) : This will likely change in the future,
409
431
as the behavior of concept-defining at-rules in shadow trees
410
432
becomes more consistently defined.
411
433
@@ -419,14 +441,15 @@ The 'syntax' Descriptor {#the-syntax-descriptor}
419
441
Initial : n/a (see prose)
420
442
</pre>
421
443
422
- Specifies the syntax of the custom property,
423
- in the form defined by [[#syntax-strings]] .
424
- This descriptor is equivalent to the {{PropertyDescriptor/syntax|syntax}} member of {{PropertyDescriptor}} .
444
+ Specifies the syntax of the [= custom property registration=]
445
+ represented by the ''@property'' rule,
446
+ controlling how the property's value is parsed at [=computed value=] time .
425
447
426
448
The 'syntax' descriptor is required for the ''@property'' rule to be valid;
427
449
if it's missing, the ''@property'' rule is invalid.
428
450
429
- If the provided string does not successfully [=consume a syntax definition|parse as a syntax definition=] ,
451
+ If the provided string is not a valid [=syntax string=]
452
+ (if it returns failure when [=consume a syntax definition=] is called on it),
430
453
the descriptor is invalid and must be ignored.
431
454
432
455
@@ -440,10 +463,11 @@ The 'inherits' Descriptor {#inherits-descriptor}
440
463
Initial : n/a (see prose)
441
464
</pre>
442
465
443
- Specifies whether or not the custom property inherits.
444
- This is equivalent to the {{PropertyDescriptor/inherits}} member of {{PropertyDescriptor}} .
466
+ Specifies the inherit flag of the [=custom property registration=]
467
+ represented by the ''@property'' rule,
468
+ controlling whether or not the property inherits by default.
445
469
446
- The inherits descriptor is required for the ''@property'' rule to be valid;
470
+ The ' inherits' descriptor is required for the ''@property'' rule to be valid;
447
471
if it's missing, the ''@property'' rule is invalid.
448
472
449
473
@@ -457,12 +481,13 @@ The 'initial-value' Descriptor {#initial-value-descriptor}
457
481
Initial : the [=guaranteed-invalid value=] (but see prose)
458
482
</pre>
459
483
460
- Specifies the [=initial value=] of the custom property.
461
- This is equivalent to the {{PropertyDescriptor/initialValue}} member of {{PropertyDescriptor}} .
484
+ Specifies the initial value of the [=custom property registration=]
485
+ represented by the ''@property'' rule,
486
+ controlling the property’s [=initial value=] .
462
487
463
488
If the value of the 'syntax' descriptor is the [=universal syntax definition=] ,
464
489
then the 'initial-value' descriptor is optional.
465
- If omitted, the initial value of the property is the [=guaranteed-invalid value=] .
490
+ If omitted, the [= initial value=] of the property is the [=guaranteed-invalid value=] .
466
491
467
492
Otherwise,
468
493
if the value of the 'syntax' descriptor is not the [=universal syntax definition=] ,
0 commit comments