Skip to content

Commit 1d6f0a6

Browse files
nainartabatkins
authored andcommitted
Fix issue 325 by adding algo for equals() (w3c#412)
* Fix issue 325 * CSSNumericValue.equals rewrite * Change equals to accept an array of values and not just one value. * Add algo for equals() * fixing nits in the code. Removing superflous cases. * formatting nit
1 parent de43e6f commit 1d6f0a6

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

css-typed-om/Overview.bs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ and parseMultiple set to true.
173173

174174
Issue(305): appropriate failure indicators for this algorithm
175175

176-
Issue(325): .equals methods for CSSStyleValue subclasses
177-
178176
<!--
179177
██████ ████████ ██ ██ ██ ████████ ██ ██ ███ ████████
180178
██ ██ ██ ██ ██ ██ ██ ███ ███ ██ ██ ██ ██
@@ -577,7 +575,6 @@ are represented by subclasses of the {{CSSNumericValue}} interface.
577575
CSSNumericValue sub(CSSNumberish... values);
578576
CSSNumericValue mul(CSSNumberish... values);
579577
CSSNumericValue div(CSSNumberish... values);
580-
581578
CSSNumericValue min(CSSNumberish... values);
582579
CSSNumericValue max(CSSNumberish... values);
583580

@@ -754,10 +751,28 @@ The following are the arithmetic operations you can perform on dimensions:
754751
is set to |values|.
755752
</div>
756753

757-
<div class=issue>
758-
Define {{CSSNumericValue/equals()}}.
754+
<div algorithm="CSSNumericValue.equals(value)">
755+
The <dfn for=CSSNumericValue method>equals(...|values|)</dfn> method,
756+
when called on a {{CSSNumericValue}} |this|,
757+
must perform the following steps:
758+
759+
1. Replace each [=list/item=] of |values|
760+
with the result of [=rectifying a numberish value=] for the [=list/item=].
761+
762+
2. Let |thisAndValues| be |this| prepended to |values|.
763+
764+
3. [=list/If all=] |item|s of |thisAndValues| do not belong to the same class return false. Example: all items in |thisAndValues| must be {{CSSUnitValue}}.
765+
766+
4. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/unit}} and {{CSSUnitValue/value}} return true.
767+
768+
5. [=list/If all=] |item|s in |thisAndValues| are {{CSSMathValue}}s :
769+
1. If |thisAndValues| are all either {{CSSMathSum}}, {{CSSMathProduct}}, {{CSSMathMin}} or {{CSSMathMax}}, iterate over the {{CSSNumericArray}}s on |thisAndValues|,
770+
1. For each {{CSSNumericValue}} in each of the {{CSSNumericArray}}s go back to step 1 to check that the {{CSSUnitValue}}s on all items in |thisAndValue| are equal.
771+
2. If |this| and |value| are both either {{CSSMathNegate}} or {{CSSMathInvert}}:
772+
1. Go back to step 1 to check that the {{CSSUnitValue}} on all items in |thisAndValue| are equal.
759773
</div>
760774

775+
761776
<div algorithm="CSSNumericValue.to()">
762777
The <dfn method for=CSSNumericValue>to(|unit|)</dfn> method converts an existing {{CSSNumericValue}} |this|
763778
into another one with the specified |unit|,

0 commit comments

Comments
 (0)