Skip to content

Commit b7047d3

Browse files
committed
[css-properties-values] More strictly define what a property registration is, in Infra terms, and refer to that in @Property. Also define how JS and CSS registrations resolve collisions.
1 parent 587ab73 commit b7047d3

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

css-properties-values-api/Overview.bs

+52-27
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,13 @@ allow custom properties to directly impact paint and layout behaviours respectiv
8383
Registered 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:
8988
giving it a syntax that's checked by the UA,
9089
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.
9493

9594
A [=custom property=] is considered to be registered for a {{Document}}
9695
if there is a valid ''@property'' rule
@@ -103,6 +102,30 @@ in the document's {{[[registeredPropertySet]]}} slot
103102
A [=registered custom property=] acts similarly to an unregistered [=custom property=],
104103
except 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+
106129
Parsing Custom Properties {#parsing-custom-properties}
107130
------------------------------------------------------
108131

@@ -164,7 +187,7 @@ Calculation of Computed Values {#calculation-of-computed-values}
164187
----------------------------------------------------------------
165188

166189
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=].
168191

169192
Note: All properties, regardless of registered syntax,
170193
accept the [=CSS-wide keywords=],
@@ -365,18 +388,12 @@ and [[css-syntax-3#tokenization|tokenizing]] the resulting string.
365388
The <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=]
369392
directly in a stylesheet
370393
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=],
372395
as 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-
380397
The 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;
389410
if either are missing,
390411
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.
396417
Unknown descriptors are invalid and ignored,
397418
but 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>>,
400422
the last one in stylesheet order "wins".
401423
A custom property registration from {{registerProperty()|CSS.registerProperty()}}
402424
further wins over any ''@property'' rules
@@ -405,7 +427,7 @@ for the same <<custom-property-name>>.
405427
A ''@property'' is invalid if it occurs in a stylesheet inside of a [=shadow tree=],
406428
and must be ignored.
407429

408-
Note: This might change in the future,
430+
Issue(939): This will likely change in the future,
409431
as the behavior of concept-defining at-rules in shadow trees
410432
becomes 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

426448
The 'syntax' descriptor is required for the ''@property'' rule to be valid;
427449
if 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),
430453
the 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;
447471
if 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

463488
If the value of the 'syntax' descriptor is the [=universal syntax definition=],
464489
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=].
466491

467492
Otherwise,
468493
if the value of the 'syntax' descriptor is not the [=universal syntax definition=],

0 commit comments

Comments
 (0)