@@ -742,20 +742,12 @@ The following are the arithmetic operations you can perform on dimensions:
742
742
3. If |sum| has more than one [=list/item=] ,
743
743
[=throw=] a {{TypeError}} .
744
744
Otherwise, let |item| be the result of [=create a CSSUnitValue from a sum value item|creating a CSSUnitValue=]
745
- from the sole [=list/item=] in |sum|.
745
+ from the sole [=list/item=] in |sum|,
746
+ then [=converting a CSSUnitValue|converting=] it to |unit|.
746
747
If |item| is failure,
747
748
[=throw=] a {{TypeError}} .
748
749
749
- 4. If |unit| and |item|’s {{CSSUnitValue/unit}} internal slot are not [=compatible units=] ,
750
- [=throw=] a {{TypeError}} .
751
-
752
- 5. If |unit| is not equal to |item|’s {{CSSUnitValue/unit}} internal slot,
753
- multiply |item|’s {{CSSUnitValue/value}} internal slot
754
- by the conversion ratio between the two units,
755
- and set its {{CSSUnitValue/unit}} internal slot
756
- to |unit|.
757
-
758
- 6. Return |item|.
750
+ 4. Return |item|.
759
751
</div>
760
752
761
753
<div algorithm>
@@ -1274,7 +1266,7 @@ are represented as {{CSSUnitValue}}s.
1274
1266
</div>
1275
1267
1276
1268
<div algorithm>
1277
- When asked to <dfn export>create a CSSUnitValue from a string</dfn> |str|,
1269
+ To <dfn export>create a CSSUnitValue from a string</dfn> |str|,
1278
1270
return a new {{CSSUnitValue}} object
1279
1271
with its {{CSSUnitValue/value}} internal slot
1280
1272
set to the numeric portion of |str| parsed into a number,
@@ -1289,6 +1281,25 @@ are represented as {{CSSUnitValue}}s.
1289
1281
</div>
1290
1282
</div>
1291
1283
1284
+ <div algorithm>
1285
+ To <dfn export>convert a CSSUnitValue</dfn> |this| to a unit |unit|,
1286
+ perform the following steps:
1287
+
1288
+ 1. Let |old unit| be the value of |this|’s {{CSSUnitValue/unit}} internal slot,
1289
+ and |old value| be the value of |this|’s {{CSSUnitValue/value}} internal slot.
1290
+
1291
+ 2. If |old unit| and |unit| are not [=compatible units=] ,
1292
+ return failure.
1293
+
1294
+ 3. Return a new {{CSSUnitValue}}
1295
+ whose {{CSSUnitValue/unit}} internal slot
1296
+ is set to |unit|,
1297
+ and whose {{CSSUnitValue/value}} internal slot
1298
+ is set to |old value| multiplied by
1299
+ the conversation ratio between |old unit| and |unit|.
1300
+ </div>
1301
+
1302
+
1292
1303
1293
1304
<!--
1294
1305
██████ ███ ██ ██████ ███ ███
0 commit comments