@@ -83,14 +83,13 @@ allow custom properties to directly impact paint and layout behaviours respectiv
8383Registered Custom Properties {#behavior-of-custom-properties}
8484=============================================================
8585
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:
8988giving it a syntax that's checked by the UA,
9089an 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 .
9493
9594A [=custom property=] is considered to be registered for a {{Document}}
9695if there is a valid ''@property'' rule
@@ -103,6 +102,30 @@ in the document's {{[[registeredPropertySet]]}} slot
103102A [=registered custom property=] acts similarly to an unregistered [=custom property=] ,
104103except as defined below.
105104
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+
106129Parsing Custom Properties {#parsing-custom-properties}
107130------------------------------------------------------
108131
@@ -164,7 +187,7 @@ Calculation of Computed Values {#calculation-of-computed-values}
164187----------------------------------------------------------------
165188
166189The [=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=] .
168191
169192Note: All properties, regardless of registered syntax,
170193accept the [=CSS-wide keywords=] ,
@@ -365,18 +388,12 @@ and [[css-syntax-3#tokenization|tokenizing]] the resulting string.
365388The <dfn>@property</dfn> Rule {#at-property-rule}
366389=================================================
367390
368- The ''@property'' rule provides an alternative way to register a custom property,
391+ The ''@property'' rule represents a [= custom property registration=]
369392directly in a stylesheet
370393without 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=] ,
372395as if {{registerProperty()}} had been called with equivalent parameters.
373396
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-
380397The syntax of ''@property'' is:
381398
382399 <pre class="prod def" nohighlight>
@@ -385,6 +402,10 @@ The syntax of ''@property'' is:
385402 }
386403 </pre>
387404
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+
388409''@property'' rules require a 'syntax' and 'inherits' descriptor;
389410if either are missing,
390411the 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.
396417Unknown descriptors are invalid and ignored,
397418but do not invalidate the ''@property'' rule.
398419
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>> ,
400422the last one in stylesheet order "wins".
401423A custom property registration from {{registerProperty()|CSS.registerProperty()}}
402424further wins over any ''@property'' rules
@@ -405,7 +427,7 @@ for the same <<custom-property-name>>.
405427A ''@property'' is invalid if it occurs in a stylesheet inside of a [=shadow tree=] ,
406428and must be ignored.
407429
408- Note : This might change in the future,
430+ Issue(939) : This will likely change in the future,
409431as the behavior of concept-defining at-rules in shadow trees
410432becomes more consistently defined.
411433
@@ -419,14 +441,15 @@ The 'syntax' Descriptor {#the-syntax-descriptor}
419441 Initial : n/a (see prose)
420442 </pre>
421443
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 .
425447
426448The 'syntax' descriptor is required for the ''@property'' rule to be valid;
427449if it's missing, the ''@property'' rule is invalid.
428450
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),
430453the descriptor is invalid and must be ignored.
431454
432455
@@ -440,10 +463,11 @@ The 'inherits' Descriptor {#inherits-descriptor}
440463 Initial : n/a (see prose)
441464 </pre>
442465
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.
445469
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;
447471if it's missing, the ''@property'' rule is invalid.
448472
449473
@@ -457,12 +481,13 @@ The 'initial-value' Descriptor {#initial-value-descriptor}
457481 Initial : the [=guaranteed-invalid value=] (but see prose)
458482 </pre>
459483
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=] .
462487
463488If the value of the 'syntax' descriptor is the [=universal syntax definition=] ,
464489then 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=] .
466491
467492Otherwise,
468493if the value of the 'syntax' descriptor is not the [=universal syntax definition=] ,
0 commit comments