You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-typed-om/Overview.bs
+39-28Lines changed: 39 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,7 @@ spec:infra;
84
84
type: dfn;
85
85
text: list
86
86
text: code point
87
+
text: string
87
88
</pre>
88
89
89
90
Introduction {#intro}
@@ -242,25 +243,22 @@ probably in an appendix.
242
243
that have transitioned from being [=single-valued=] to [=list-valued=].
243
244
To ensure that code written at a time when a property was [=single-valued=]
244
245
does not break when it becomes [=list-valued=] in the future,
245
-
the {{CSSPropertyMap}} is a <b>multi-map</b>;
246
+
the {{StylePropertyMap}} is a <b>multi-map</b>;
246
247
it stores <em>list</em> of values for each key,
247
248
but allows you to interact with it as if there was only a single value for each key as well.
248
249
249
-
This means that multiple values for a single property in a {{CSSPropertyMap}}
250
+
This means that multiple values for a single property in a {{StylePropertyMap}}
250
251
do not represent multiple successive definition of that property's value;
251
252
instead, they represent multiple comma-separated sub-values in a single property value,
252
253
like each "layer" in a 'background-image' property.
253
254
</div>
254
255
255
-
The <dfn method for=StylePropertyMap>append(DOMString <var>property</var>,
256
-
(CSSStyleValue or DOMString)... <var>values</var>)</dfn> method, when invoked, must
257
-
[=append to a StylePropertyMap=] with property <var>property</var> and values <var>values</var>.
258
-
259
256
<div algorithm>
260
-
To <dfn>append to a StylePropertyMap</dfn> given a <var>property</var> and a list of
261
-
<var>values</var>, run these steps:
257
+
The <dfn method for=StylePropertyMap>append(|property|, ...|values|)</dfn> method,
258
+
when called on a {{StylePropertyMap}} |this|,
259
+
must perform the following steps:
262
260
263
-
1. If |property| does not start with two dashes (U+002D HYPHEN),
261
+
1. If |property| is not a [=custom property name string=],
264
262
let |property| be |property| [=ASCII lowercased=].
265
263
266
264
2. If |property| is not a [=supported property name=],
@@ -269,17 +267,20 @@ The <dfn method for=StylePropertyMap>append(DOMString <var>property</var>,
269
267
3. If |property| is not a [=list-valued property=],
270
268
[=throw=] a {{TypeError}} and exit this algorithm.
271
269
272
-
4. If {{StylePropertyMap}}’s [=contained properties map=] contains an entry for |property|,
273
-
let |entry| be that entry.
274
-
Otherwise, create a new entry for |property| with an empty list,
275
-
add it to the [=contained properties map=],
276
-
and let |entry| be the newly-created entry.
270
+
4. Let |props| be |this|’s [=contained properties map=].
277
271
278
-
5. Let |values to append| be the empty list.
272
+
5. If |props|[|property|] does not [=map/exist=],
273
+
[=map/set=] |props|[|property|] to an empty [=list=].
279
274
280
-
6. For each |value| in |values| if the <a>algorithm that coerces |value| into an appropriate type for a given property</a> does not throw an error, append the returned object to |values to append|.
275
+
6. Let |temp values| be an empty [=list=].
281
276
282
-
7. Append |values to append| to the end of |entry|’s list.
277
+
7. For each |value| in |values|,
278
+
[=normalize a style value=] with |property| and |value|,
279
+
and [=list/append=] the returned value to |temp values|.
280
+
281
+
<!-- Using a temp list so that nothing gets mutated if normalizing ends up throwing an error. -->
282
+
283
+
8. [=list/Append=] the entries of |temp values| to |props|[|property|].
283
284
</div>
284
285
285
286
<div algorithm>
@@ -296,17 +297,20 @@ The <dfn method for=StylePropertyMap>append(DOMString <var>property</var>,
296
297
</div>
297
298
298
299
<div algorithm>
299
-
This section describes the <dfn>algorithm that coerces value into an appropriate type for a given property</dfn>, or fails and throws a {{TypeError}}:
300
-
: If |value| is a {{CSSStyleValue}},
301
-
:: If |value| does not match the grammar of a [=list-valued property iteration=] of |property|,
302
-
[=throw=] a {{TypeError}} and exit this algorithm.
303
-
Otherwise, return the |value|.
304
-
: If |value| is a {{DOMString}},
305
-
:: [=Parse a CSSStyleValue=] with property |property| and value |value| and return the resulting |value|.
306
-
If the result is null,
307
-
[=throw=] a {{TypeError}} and exit this algorithm.
308
-
Otherwise, append each [=list-valued property iteration=] in the result to a |values to append| object
309
-
and return |values to append|.
300
+
To <dfn export>normalize a style value</dfn>,
301
+
given a [=string=] |property|
302
+
and a [=string=] or {{CSSStyleValue}} |value|:
303
+
304
+
: If |value| is a {{CSSStyleValue}},
305
+
:: If |value| does not match the grammar of a [=list-valued property iteration=] of |property|,
306
+
[=throw=] a {{TypeError}} and exit this algorithm.
307
+
Otherwise, return the |value|.
308
+
309
+
: If |value| is a {{DOMString}},
310
+
:: [=Parse a CSSStyleValue=] with property |property|, value |value|, and |parseMultiple| set to `false`,
311
+
and return the result.
312
+
313
+
Note: This can throw a {{TypeError}} instead.
310
314
</div>
311
315
312
316
<div algorithm>
@@ -415,6 +419,13 @@ the [=contained properties map=]. This list of properties is sorted in the follo
415
419
416
420
[=computed StylePropertyMap=], [=declared StylePropertyMap=] and [=inline StylePropertyMap=] are all live objects: the attributes and methods on these objects must operate on the actual underlying data, not a snapshot of the data.
417
421
422
+
A [=string=] is a <dfn>custom property name string</dfn>
423
+
if it starts with two dashes (U+002D HYPHEN-MINUS), like <code>--foo</code>.
424
+
(This corresponds to the <<custom-property-name>> production,
425
+
but applies to [=strings=],
426
+
rather than [=identifiers=];
427
+
it can be used without invoking the CSS parser.)
428
+
418
429
Issue(148): add detailed descriptions of the rest of the methods on {{StylePropertyMap}}
0 commit comments