Skip to content

Commit ad771ba

Browse files
committed
Rewrite append() into proper algorithmic style. Fixes #143.
1 parent b7d0f46 commit ad771ba

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

css-typed-om/Overview.bs

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -130,34 +130,41 @@ future without breaking code that relies on calling
130130
{{StylePropertyMap/set()}} for those properties.
131131
</div>
132132

133-
When invoked, the
134-
<dfn method for=StylePropertyMap>append(DOMString <var>property</var> (CSSStyleValue or DOMString)... <var>values</var>)</dfn>
135-
method follows the following steps:
136-
137-
Issue(143): first need to check whether the property is a valid property.
138-
139-
1.
140-
: if <var>property</var> is not list-valued
141-
:: throw a TypeError
142-
143-
2.
144-
: if the <a>property model</a> has no entry for <var>property</var>
145-
:: initialize an empty sequence in the <a>property model</a> for <var>property</var>
146-
147-
3.
148-
: for each <var>value</var> in <var>values</var>, if <var>value</var> is a {{CSSStyleValue}}, and its type is a type that <var>property</var> can't accept
149-
:: throw a TypeError
150-
151-
4.
152-
: for each <var>value</var> in <var>values</var>, if <var>value</var> is a DOMString
153-
:: set <var>value</var> to the result of invoking {{CSSStyleValue/parse()}}, providing <var>property</var>
154-
and <var>value</var> as inputs.
155-
156-
5.
157-
: if any <var>value</var> in <var>values</var> is null
158-
:: throw a TypeError
159-
: else
160-
:: concatenate <var>values</var> onto the end of the entry in the <a>property model</a>
133+
<div algorithm="append to a StylePropertyMap">
134+
The <dfn method for=StylePropertyMap>append(DOMString <var>property</var> (CSSStyleValue or DOMString)... <var>values</var>)</dfn> method,
135+
when invoked,
136+
must run these steps:
137+
138+
1. If |property| does not start with two dashes (U+002D HYPHEN),
139+
let |property| be |property| <a>converted to ASCII lowercase</a>.
140+
141+
2. If |property| is not a <a>supported property name</a>,
142+
<a>throw</a> a {{TypeError}} and exit this algorithm.
143+
144+
3. If |property| is not a <a>list-valued property</a>,
145+
<a>throw</a> a {{TypeError}} and exit this algorithm.
146+
147+
4. If {{StylePropertyMap}}’s <a>property model</a> contains an entry for |property|,
148+
let |entry| be that entry.
149+
Otherwise, create a new entry for |property| with an empty list,
150+
add it to the <a>property model</a>,
151+
and let |entry| be the newly-created entry.
152+
153+
5. Let |values to append| be the empty list.
154+
155+
6. For each |value| in |values|:
156+
: If |value| is a {{CSSStyleValue}},
157+
:: If |value|’s type is not one that |property| is defined to accept,
158+
<a>throw</a> a {{TypeError}} and exit this algorithm.
159+
Otherwise, append |value| to the end of |values to append|.
160+
: If |value| is a {{DOMString}},
161+
:: <a>Parse a CSSStyleValue</a> with property |property| and value |value|.
162+
If the result is null,
163+
<a>throw</a> a {{TypeError}} and exit this algorithm.
164+
Otherwise, append the result to the end of |values to append|.
165+
166+
7. Append |values to append| to the end of |entry|’s list.
167+
</div>
161168

162169

163170
The <dfn method for=StylePropertyMap>getProperties()</dfn> method returns all of the properties listed in

0 commit comments

Comments
 (0)