@@ -80,8 +80,86 @@ allow custom properties to directly impact paint and layout behaviours respectiv
80
80
████████ ████████ ██ ██ ██ ██ ███ ████ ███████ ██ ██
81
81
-->
82
82
83
- Behavior of Custom Properties {#behavior-of-custom-properties}
84
- ==============================================================
83
+ Registered Custom Properties {#behavior-of-custom-properties}
84
+ =============================================================
85
+
86
+ A [=custom property=] can,
87
+ with the methods defined in this specification,
88
+ become a <dfn>registered custom property</dfn> ,
89
+ giving it a syntax that's checked by the UA,
90
+ an initial value,
91
+ and a specific inheritance behavior,
92
+ making the [=custom property=]
93
+ act more like a UA-defined property.
94
+
95
+ A [=custom property=] is considered to be registered for a {{Document}}
96
+ if there is a valid ''@property'' rule
97
+ defined for its name
98
+ in one of the document's stylesheets,
99
+ or its name is [=map/contains|contained=]
100
+ in the document's {{[[registeredPropertySet]]}} slot
101
+ (that is, {{registerProperty()}} was called to register it).
102
+
103
+ A [=registered custom property=] acts similarly to an unregistered [=custom property=] ,
104
+ except as defined below.
105
+
106
+ Parsing Custom Properties {#parsing-custom-properties}
107
+ ------------------------------------------------------
108
+
109
+ [=Registered custom properties=] parse exactly like unregistered [=custom properties=] ;
110
+ almost anything is allowed.
111
+ The registered syntax of the property is <em> not</em> checked at parse time.
112
+
113
+ Note: However,
114
+ the syntax is checked at computed-value time,
115
+ before substitution via ''var()'' .
116
+ See [[#computed-value]] .
117
+
118
+ <details class=note>
119
+ <summary> Why aren't custom properties syntax-checked?</summary>
120
+
121
+ When parsing a page's CSS,
122
+ UAs commonly make a number of optimizations
123
+ to help with both speed and memory.
124
+
125
+ One of those optimizations
126
+ is that they only store the properties that will actually have an effect;
127
+ they throw away invalid properties,
128
+ and if you write the same property multiple times in a single declaration block,
129
+ all but the last valid one will be thrown away.
130
+
131
+ This works fine if the syntax of a property never changes over the lifetime of a page.
132
+ If a custom property is registered, however,
133
+ it can change its syntax,
134
+ so that a property that was previously invalid
135
+ suddenly becomes valid.
136
+
137
+ The only way to handle this is to either store every declaration,
138
+ even those that were initially invalid
139
+ (increasing the memory cost of pages),
140
+ or re-parsing the entire page's CSS
141
+ with the new syntax rules
142
+ (increasing the processing cost of registering a custom property).
143
+ Neither of these are very desirable.
144
+
145
+ Further,
146
+ UA-defined properties have their syntax determined
147
+ by the version of the UA the user is viewing the page with;
148
+ this is out of the page author's control,
149
+ which is the entire reason for CSS's error-recovery behavior
150
+ and the practice of writing multiple declarations for varying levels of support.
151
+ A custom property, on the other hand,
152
+ has its syntax controlled by the page author;
153
+ there's no unpredictability to be managed.
154
+ Throwing away syntax-violating custom properties
155
+ would thus only be, at best, a convenience for the page author,
156
+ not a necessity like for UA-defined properties.
157
+ </details>
158
+
159
+ Computed Value of Custom Properties {#computed-value}
160
+ -----------------------------------------------------
161
+
162
+ Issue: Move computed value behavior here.
85
163
86
164
Animation Behavior of Custom Properties {#animation-behavior-of-custom-properties}
87
165
----------------------------------------------------------------------------------
@@ -361,7 +439,7 @@ Registering a custom property must <strong>not</strong> affect the [=cascade=] i
361
439
Regardless of what syntax is specified for a registered property,
362
440
at parse time it is still parsed as normal for a [=custom property=] ,
363
441
accepting nearly anything.
364
- If the [=specified value=] for a registered [= custom property=]
442
+ If the [=specified value=] for a [=registered custom property=]
365
443
violates the registered syntax,
366
444
however,
367
445
the property becomes [=invalid at computed-value time=]
0 commit comments