Skip to content

Commit 89a8706

Browse files
committed
Move the 'generate type from unit', and rely on that directly.
1 parent 8f88dcf commit 89a8706

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

css-typed-om/Overview.bs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,34 @@ The ordering of a [=type=]’s entries always matches this [=base type=] orderin
868868
The <dfn for=CSSNumericValue>percent hint</dfn>
869869
is either null or a [=base type=] other than "percent".
870870

871+
<div algorithm>
872+
To <dfn lt="create a type|creating a type">create a type</dfn> from a string |unit|,
873+
follow the appropriate branch of the following:
874+
875+
<dl class=switch>
876+
: |unit| is "number"
877+
:: Return «[ ]» (empty map)
878+
: |unit| is "percent"
879+
:: Return «[ "percent" → 1 ]»
880+
: |unit| is a <<length>> unit
881+
:: Return «[ "length" → 1 ]»
882+
: |unit| is an <<angle>> unit
883+
:: Return «[ "angle" → 1 ]»
884+
: |unit| is a <<time>> unit
885+
:: Return «[ "time" → 1 ]»
886+
: |unit| is a <<frequency>> unit
887+
:: Return «[ "frequence" → 1 ]»
888+
: |unit| is a <<resolution>> unit
889+
:: Return «[ "resolution" → 1 ]»
890+
: |unit| is a <<flex>> unit
891+
:: Return «[ "flex" → 1 ]»
892+
: anything else
893+
:: Return failure.
894+
</dl>
895+
896+
In all cases, the associated [=percent hint=] is null.
897+
</div>
898+
871899
<div algorithm>
872900
To <dfn local-lt="add | addition">add two types</dfn> |type1| and |type2|,
873901
perform the following steps:
@@ -1050,7 +1078,7 @@ are represented as {{CSSUnitValue}}s.
10501078
when called,
10511079
perform the following steps:
10521080

1053-
1. If |unit| does not have a [=CSS type=],
1081+
1. If [=creating a type=] from |unit| returns failure,
10541082
[=throw=] a {{SyntaxError}}
10551083
and abort this algorithm.
10561084

@@ -1064,7 +1092,7 @@ are represented as {{CSSUnitValue}}s.
10641092
on setting a value |unit|,
10651093
perform the following steps:
10661094

1067-
1. If |unit| does not have a [=CSS type=],
1095+
1. If [=creating a type=] from |unit| returns failure,,
10681096
[=throw=] a {{TypeError}}.
10691097

10701098
2. Otherwise,
@@ -1081,32 +1109,9 @@ are represented as {{CSSUnitValue}}s.
10811109
Issue: Figure out how we're exposing types. This should probably move up to the superclass, then.
10821110
</div>
10831111

1084-
<div algorithm="CSS type of a unit">
1085-
The [=type=] of a {{CSSUnitValue}}
1086-
depends on its {{CSSUnitValue/unit}} as follows:
1087-
1088-
<dl class=switch>
1089-
: |unit| is "number"
1090-
:: [=type=] is «[ ]» (empty map)
1091-
: |unit| is "percent"
1092-
:: [=type=] is «[ "percent" → 1 ]»
1093-
: |unit| is a <<length>> unit
1094-
:: [=type=] is «[ "length" → 1 ]»
1095-
: |unit| is an <<angle>> unit
1096-
:: [=type=] is «[ "angle" → 1 ]»
1097-
: |unit| is a <<time>> unit
1098-
:: [=type=] is «[ "time" → 1 ]»
1099-
: |unit| is a <<frequency>> unit
1100-
:: [=type=] is «[ "frequence" → 1 ]»
1101-
: |unit| is a <<resolution>> unit
1102-
:: [=type=] is «[ "resolution" → 1 ]»
1103-
: |unit| is a <<flex>> unit
1104-
:: [=type=] is «[ "flex" → 1 ]»
1105-
: anything else
1106-
:: the string does not have a [=CSS type=]
1107-
</dl>
1108-
1109-
In all cases, the [=percent hint=] of the [=type=] is null.
1112+
<div algorithm>
1113+
The <dfn>[=type=] of a {{CSSUnitValue}}</dfn>
1114+
is the result of [=creating a type=] from its {{CSSUnitValue/unit}} internal slot.
11101115
</div>
11111116

11121117
<div algorithm>

0 commit comments

Comments
 (0)