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
A {{StylePropertyMapReadOnly}} object has an associated <dfn export for="StylePropertyMapReadonly, StylePropertyMap">contained properties map</dfn>,
218
220
which is a [=map=] of property name ([=string=]) → values ([=list=] of {{CSSStyleValue}} objects) pairs.
@@ -284,16 +286,18 @@ probably in an appendix.
284
286
</div>
285
287
286
288
<div algorithm>
287
-
To <dfn>delete a StylePropertyMap</dfn> given a <var>property</var>, run these steps:
289
+
The <dfn method for=StylePropertyMap>delete(|property|)</dfn> method,
290
+
when called on a {{StylePropertyMap}} |this|,
291
+
must perform the following steps:
288
292
289
-
1. If |property| does not start with two dashes (U+002D HYPHEN),
293
+
1. If |property| is not a [=custom property name string=],
290
294
let |property| be |property| [=ASCII lowercased=].
291
295
292
296
2. If |property| is not a [=supported property name=],
293
297
[=throw=] a {{TypeError}} and exit this algorithm.
294
298
295
-
3. If {{StylePropertyMap}}’s [=contained properties map=] contains an entry for |property|,
296
-
remove that entry from the [=contained properties map=].
299
+
3. If |this|’s [=contained properties map=][=contains=] |property|,
300
+
[=map/remove=] it.
297
301
</div>
298
302
299
303
<div algorithm>
@@ -307,109 +311,94 @@ probably in an appendix.
307
311
Otherwise, return the |value|.
308
312
309
313
: If |value| is a {{DOMString}},
310
-
:: [=Parse a CSSStyleValue=] with property |property|, value |value|, and |parseMultiple| set to `false`,
314
+
:: [=Parse a CSSStyleValue=] with property |property|, value |value|, and parseMultiple set to `false`,
311
315
and return the result.
312
316
313
317
Note: This can throw a {{TypeError}} instead.
314
318
</div>
315
319
316
320
<div algorithm>
317
-
To <dfn>get a value from a StylePropertyMap</dfn>, run these steps:
321
+
The <dfn method for="StylePropertyMapReadonly, StylePropertyMap">get(|property|)</dfn> method,
322
+
when called on a {{StylePropertyMap}} |this|,
323
+
must perform the following steps:
318
324
319
325
1. If |property| does not start with two dashes (U+002D HYPHEN),
320
326
let |property| be |property| [=ASCII lowercased=].
321
327
322
328
2. If |property| is not a [=supported property name=],
323
329
[=throw=] a {{TypeError}} and exit this algorithm.
324
330
325
-
3. If {{StylePropertyMap}}’s [=contained properties map=] contains an entry for |property|,
326
-
return the first value found in that entry.
331
+
3. Let |props| be |this|’s [=contained properties map=].
332
+
333
+
4. If |props|[|property|][=map/exists=],
334
+
return |props|[|property|][0].
327
335
328
-
4. Else, return `null`.
336
+
Otherwise, return `undefined`.
329
337
</div>
330
338
331
339
<div algorithm>
332
-
To <dfn>get all values from a StylePropertyMap</dfn>, run these steps:
340
+
The <dfn method for="StylePropertyMapReadonly, StylePropertyMap">getAll(|property|)</dfn> method,
341
+
when called on a {{StylePropertyMap}} |this|,
342
+
must perform the following steps:
333
343
334
344
1. If |property| does not start with two dashes (U+002D HYPHEN),
335
345
let |property| be |property| [=ASCII lowercased=].
336
346
337
347
2. If |property| is not a [=supported property name=],
338
348
[=throw=] a {{TypeError}} and exit this algorithm.
339
-
340
-
3. If {{StylePropertyMap}}’s [=contained properties map=] contains an entry for |property|:
341
-
342
-
1. If |property| is a [=list-valued property=],
343
-
return the list of |values| assigned to that property.
344
-
345
-
2. If |property| is not a [=list-valued property=],
346
-
let |values| initially be the empty [=list=] and append
347
-
the |value| assigned to the |property| to this list
348
-
and return |values|.
349
-
350
-
4. Else, return an empty [=list=].
351
-
352
-
</div>
353
-
354
-
<div algorithm>
355
-
To <dfn>check if StylePropertyMap has a property</dfn>, run these steps:
356
-
357
-
1. Run the algorithm to [=get a value from a StylePropertyMap=] with property <var>property</var>,
358
-
1. If the algorithm returns a {{CSSStyleValue}} return true.
359
349
360
-
2. If the algorithm returns `null` return false.
350
+
3. Let |props| be |this|’s [=contained properties map=].
361
351
352
+
4. If |props|[|property|][=map/exists=],
353
+
return |props|[|property|].
354
+
Otherwise, return an empty [=list=].
362
355
</div>
363
356
364
-
365
357
<div algorithm>
366
-
To <dfn>set a value on a StylePropertyMap</dfn>,
367
-
given a [=string=] |property|
368
-
and a [=list=] of {{CSSStyleValue}} objects |value|,
369
-
run these steps:
358
+
The <dfn method for=StylePropertyMap>set(|property|, ...|values|)</dfn> method,
359
+
when called on a {{StylePropertyMap}} |this|,
360
+
must perform the following steps:
370
361
371
362
1. If |property| does not start with two dashes (U+002D HYPHEN),
372
363
let |property| be |property| [=ASCII lowercased=].
373
364
374
365
2. If |property| is not a [=supported property name=],
375
366
[=throw=] a {{TypeError}} and exit this algorithm.
376
367
377
-
3. If {{StylePropertyMap}}’s [=contained properties map=] contains an entry for |property|,
378
-
let |entry| be that entry.
379
-
Otherwise, exit the algorithm.
368
+
3. Let |props| be |this|’s [=contained properties map=].
380
369
381
-
4. Empty the list of |values| currently stored on the |entry|.
370
+
4. If |props|[|property|][=map/exists=],
371
+
[=map/remove=] it.
382
372
383
-
5. Let |values to set| be an empty list.
373
+
5. Let |values to set| be an empty [=list=].
384
374
385
-
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 set|.
375
+
6. For each |value| in |values|:
376
+
1. [=Normalize a style value=] for |property| and |value|,
377
+
and append the result to |values to set|.
386
378
387
-
7. Set |values to set| to be |entry|’s list.
388
-
</div>
379
+
7. Set |props|[|property|] to |values to set|.
389
380
390
-
The <dfn method for=StylePropertyMap>update(DOMString <var>property</var>,
391
-
UpdateFunction <var>updateFunction</var>)</dfn> method, when invoked, must
392
-
[=update a value in a StylePropertyMap=] with property name
393
-
<var>property</var>, update function <var>updateFunction</var>, and property
394
-
map set to the object this method was invoked on .
381
+
Note: The property is deleted then added back
382
+
so that it gets put at the end of the [=ordered map=],
383
+
which gives the expected behavior in the face of [=shorthand properties=].
384
+
</div>
395
385
396
386
<div algorithm>
397
-
To <dfn>update a value in a StylePropertyMap</dfn> given a <var>property
398
-
name</var>, <var>update function</var>, and <var>property map</var>, run these
399
-
steps:
400
-
401
-
1. Let <var>old value</var> be the result of running the algorithm to
402
-
[=get a value from a StylePropertyMap=] with property name <var>property
403
-
name</var> and property map <var>property map</var>.
387
+
The <dfn method for=StylePropertyMap>update(|property|, |updateFn|)</dfn> method,
388
+
when called on a {{StylePropertyMap}} |this|,
389
+
must perform the following steps:
404
390
405
-
2. Let <var>new value</var> be the return value given by [=invoking=] the callback
406
-
<var>update function</var> with a single input of <var>old value</var>.
391
+
1. Let |old value| be the result of calling |this|.get(|property|)
392
+
(using the original value of {{StylePropertyMap/get()}}).
407
393
408
-
3. Run the algorithm to [=set a value on a StylePropertyMap=] with property name <var>property name</var>,
409
-
value <var>new value</var>, and property map <var>property map</var>.
394
+
2. Let |new value| be the result of [=invoking=] |updateFn| with |old value|.
410
395
396
+
3. Call |this|.set(|property|, |new value|)
397
+
(using the original value of {{StylePropertyMap/set()}}).
411
398
</div>
412
399
400
+
Issue: Do we need an updateAll() method that gets and sets a list?
401
+
413
402
The <dfn method for=StylePropertyMap>getProperties()</dfn> method returns all of the contained properties maped in
414
403
the [=contained properties map=]. This list of properties is sorted in the following manner:
0 commit comments