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
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
@@ -577,7 +575,6 @@ are represented by subclasses of the {{CSSNumericValue}} interface.
577
575
CSSNumericValue sub(CSSNumberish... values);
578
576
CSSNumericValue mul(CSSNumberish... values);
579
577
CSSNumericValue div(CSSNumberish... values);
580
-
581
578
CSSNumericValue min(CSSNumberish... values);
582
579
CSSNumericValue max(CSSNumberish... values);
583
580
@@ -754,10 +751,28 @@ The following are the arithmetic operations you can perform on dimensions:
754
751
is set to |values|.
755
752
</div>
756
753
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.
759
773
</div>
760
774
775
+
761
776
<div algorithm="CSSNumericValue.to()">
762
777
The <dfn method for=CSSNumericValue>to(|unit|)</dfn> method converts an existing {{CSSNumericValue}} |this|
0 commit comments