-
Notifications
You must be signed in to change notification settings - Fork 142
Fix issue 325 by adding algo for equals() #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
css-typed-om/Overview.bs
Outdated
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: | ||
|
||
1. If the |value| item is the same type as the {{CSSNumericValue}} the method is being called on continue to step 2, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to continue on to step 2 as this happens automatically. Maybe rewrite as 'If |value| is of different type to |this|, return false.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we need to define what 'different type' means.
css-typed-om/Overview.bs
Outdated
The <dfn for=CSSNumericValue method>equals(...|value|)</dfn> method, | ||
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to either explicitly iterate over |value| (change to values?) or just restrict this to take a single value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And by "or" Shane means "do the first thing", because all the other methods take multiple values too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had done the first thing. Commit 3 should make equals accept an array.
css-typed-om/Overview.bs
Outdated
|
||
1. If the |value| item is the same type as the {{CSSNumericValue}} the method is being called on continue to step 2, else return false. | ||
|
||
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as step 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was supposed to be class.
css-typed-om/Overview.bs
Outdated
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. | ||
|
||
3. If the |value| item has the same unit as the {{CSSNumericValue}} return true, else return false. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to handle calc values, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
<div class=issue> | ||
Define {{CSSNumericValue/equals()}}. | ||
<div algorithm="CSSNumericValue.equals(...|value|)"> | ||
The <dfn for=CSSNumericValue method>equals(...|value|)</dfn> method, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that .equals() is variadic; you have to check that all the values are equal to each other/this.
css-typed-om/Overview.bs
Outdated
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: | ||
|
||
1. If the |value| item is the same type as the {{CSSNumericValue}} the method is being called on continue to step 2, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Just reverse this conditional and return false. No need to explicitly say to go to the next step; that's implied by the list.
- Be clear what you mean by "type" - you use the exact same word in the second step, but clearly mean something different. I suspect here you're talking about the interface type.
- "the CSSNumericValue the method is being called on" is already stored in the
|this|
variable, so you just refer to it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
|
||
1. If the |value| item is the same type as the {{CSSNumericValue}} the method is being called on continue to step 2, else return false. | ||
|
||
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Same concerns as about the structure; reverse the conditional and just return false.
- I think you mean "value" here? Refer to
|this|’s {{CSSUnitValue/value}} internal slot
then (and same for |value|).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
|
||
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. | ||
|
||
3. If the |value| item has the same unit as the {{CSSNumericValue}} return true, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use {{CSSUnitValue/unit}} internal slot
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
<div algorithm="CSSNumericValue.equals(...|value|)"> | ||
The <dfn for=CSSNumericValue method>equals(...|value|)</dfn> method, | ||
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The algo claims to be defined for CSSNumericValue, but the steps assume that you're looking at a CSSUnitValue. It needs to work for all the CSSMathValue subtypes too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
Whoops, I still had this page up from earlier, and it hadn't updated with Shane's comments. Sorry for doubling up. ^_^ |
I suck at Github but I have added a new commit. Hopefully that addresses both @shans and @tabatkins comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 3 makes equals accept an array of values instead of just one value. Take a look?
css-typed-om/Overview.bs
Outdated
<div algorithm="CSSNumericValue.equals(...|value|)"> | ||
The <dfn for=CSSNumericValue method>equals(...|value|)</dfn> method, | ||
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
The <dfn for=CSSNumericValue method>equals(...|value|)</dfn> method, | ||
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had done the first thing. Commit 3 should make equals accept an array.
css-typed-om/Overview.bs
Outdated
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. | ||
|
||
3. If the |value| item has the same unit as the {{CSSNumericValue}} return true, else return false. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
when called on a {{CSSNumericValue}} |this|, | ||
must perform the following steps: | ||
|
||
1. If the |value| item is the same type as the {{CSSNumericValue}} the method is being called on continue to step 2, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
|
||
1. If the |value| item is the same type as the {{CSSNumericValue}} the method is being called on continue to step 2, else return false. | ||
|
||
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
css-typed-om/Overview.bs
Outdated
|
||
2. If the |value| item has the same type as the {{CSSNumericValue}} continue to the next step, else return false. | ||
|
||
3. If the |value| item has the same unit as the {{CSSNumericValue}} return true, else return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking much better overall, just some nits left.
css-typed-om/Overview.bs
Outdated
|
||
1. [=list/If all=] |item|s of |thisAndValues| do not belong to the same class return false. Example: all items in |thisAndValues| must be {{CSSUnitValue}}. | ||
|
||
2. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/value}} return true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit and value ^_^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
css-typed-om/Overview.bs
Outdated
|
||
2. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/value}} return true. | ||
|
||
4. =list/If all=] |item|s in |thisAndValues| are {{CSSMathValue}s : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing [
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
css-typed-om/Overview.bs
Outdated
2. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/value}} return true. | ||
|
||
4. =list/If all=] |item|s in |thisAndValues| are {{CSSMathValue}s : | ||
1. If the {{CSSMathValue/operator}} are not equal for all {{CSSMathValues}} in |thisAndValues| return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already covered by "same class" earlier, so you can drop this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
css-typed-om/Overview.bs
Outdated
1. If the {{CSSMathValue/operator}} are not equal for all {{CSSMathValues}} in |thisAndValues| return false. | ||
2. If |thisAndValues| are all either {{CSSMathSum}}, {{CSSMathProduct}}, {{CSSMathMin}} or {{CSSMathMax}}, iterate over the {{CSSNumericArray}}s on |thisAndValues|, | ||
1. For each {{CSSUnitValue}} in each of the {{CSSNumericArray}}s go back to step 1 to check that the {{CSSUnitValue}}s on all items in |thisAndValue| are equal. | ||
3. If |this| and |value| are both either {{CSSMathNegate}} or {{CSSMathInvert}}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to handle multiples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean CSSMathProduct? Cause that is dealt with in the above step. Or do you mean the case where values in |thisAndValues| are not all of the same type? If the latter in that case we should return a false right?
@tabatkins took a stab at equals take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tabatkins made the changes and had a follow up question.
css-typed-om/Overview.bs
Outdated
|
||
1. [=list/If all=] |item|s of |thisAndValues| do not belong to the same class return false. Example: all items in |thisAndValues| must be {{CSSUnitValue}}. | ||
|
||
2. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/value}} return true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
css-typed-om/Overview.bs
Outdated
|
||
2. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/value}} return true. | ||
|
||
4. =list/If all=] |item|s in |thisAndValues| are {{CSSMathValue}s : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
css-typed-om/Overview.bs
Outdated
2. [=list/If all=] |item|s in |thisAndValues| are {{CSSUnitValue}s and have the same {{CSSUnitValue/value}} return true. | ||
|
||
4. =list/If all=] |item|s in |thisAndValues| are {{CSSMathValue}s : | ||
1. If the {{CSSMathValue/operator}} are not equal for all {{CSSMathValues}} in |thisAndValues| return false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
css-typed-om/Overview.bs
Outdated
1. If the {{CSSMathValue/operator}} are not equal for all {{CSSMathValues}} in |thisAndValues| return false. | ||
2. If |thisAndValues| are all either {{CSSMathSum}}, {{CSSMathProduct}}, {{CSSMathMin}} or {{CSSMathMax}}, iterate over the {{CSSNumericArray}}s on |thisAndValues|, | ||
1. For each {{CSSUnitValue}} in each of the {{CSSNumericArray}}s go back to step 1 to check that the {{CSSUnitValue}}s on all items in |thisAndValue| are equal. | ||
3. If |this| and |value| are both either {{CSSMathNegate}} or {{CSSMathInvert}}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean CSSMathProduct? Cause that is dealt with in the above step. Or do you mean the case where values in |thisAndValues| are not all of the same type? If the latter in that case we should return a false right?
Gonna go ahead and merge and fix things up myself.
@shans could you take a look, took a stab at writing up the algo for .equals()