Skip to content

Commit 4efe2f5

Browse files
nainarshans
authored andcommitted
Refactor out value type-checking logic from CSSStyleValue.append to fix issue w3c#145 (w3c#429)
* refactor out value type-checking logic from CSSStyleValue.append to fix issue w3c#145 * Remove issue from spec * Fix up algorithm referencing
1 parent 7d17de5 commit 4efe2f5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

css-typed-om/Overview.bs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,23 @@ The <dfn method for=StylePropertyMap>append(DOMString <var>property</var>,
250250

251251
5. Let |values to append| be the empty list.
252252

253-
6. For each |value| in |values|:
253+
6. For each |value| in |values| if the [=algorithm that coerces value into an appropriate type for a given property=] does not throw an error, append the returned object to |values to append|.
254+
255+
7. Append |values to append| to the end of |entry|’s list.
256+
</div>
257+
258+
<div algorithm>
259+
This section describes the <dfn>algorithm that coerces value into an appropriate type for a given property</dfn>, or fails and throws a {{TypeError}}:
254260
: If |value| is a {{CSSStyleValue}},
255261
:: If |value| does not match the grammar of a [=list-valued property iteration=] of |property|,
256262
[=throw=] a {{TypeError}} and exit this algorithm.
257-
Otherwise, append |value| to the end of |values to append|.
263+
Otherwise, return the |value|.
258264
: If |value| is a {{DOMString}},
259-
:: [=Parse a CSSStyleValue=] with property |property| and value |value|.
265+
:: [=Parse a CSSStyleValue=] with property |property| and value |value| and return the resulting |value|.
260266
If the result is null,
261267
[=throw=] a {{TypeError}} and exit this algorithm.
262-
Otherwise, append each [=list-valued property iteration=] in the result to the end of |values to append|.
263-
264-
7. Append |values to append| to the end of |entry|’s list.
268+
Otherwise, append each [=list-valued property iteration=] in the result to a |values to append| object
269+
and return |values to append|.
265270
</div>
266271

267272
<div algorithm>
@@ -309,8 +314,6 @@ the [=property model=]. This list of properties is sorted in the following manne
309314

310315
[=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.
311316

312-
Issue(145): should refactor out value type-checking, as it'll be needed by the rest of the setters too
313-
314317
Issue(148): add detailed descriptions of the rest of the methods on {{StylePropertyMap}}
315318

316319
Issue(268): stringification

0 commit comments

Comments
 (0)