Skip to content

[css-typed-om-1] "equal numeric values" may return false when people might expect true #682

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

Closed
bzbarsky opened this issue Feb 16, 2018 · 5 comments

Comments

@bzbarsky
Copy link

Consider the output of https://drafts.css-houdini.org/css-typed-om-1/#equal-numeric-value on these two values:

CSSMathNegate(CSSMathSum(2px, 1em))
CSSMathSum(-2px, -1em)

I believe you can produce those data structures, and that this algorithm will return false in this case, right?

I'm not sure I have a nice suggestion here, by the way; solving this in general is not trivial.

@darrnshn
Copy link
Collaborator

Yeah it will currently return false. There are many definitions of "equal" that we can go with here (some easy, some intractable). I think we should just pick one that's not too opinionated and allow the user to define fancier equalities as they desire by traversing the tree.

Some ideas:

  1. Structural equality where order matters (i.e. CSSMathSum(1px, 2px) != CSSMathSum(2px, 1px)).
  2. Structural equality where order doesn't matter (i.e. CSSMathSum(1px, 2px) == CSSMathSum(2px, 1ps)).
  3. Structural equality after "simplification" (i.e. your example will return true).

IMHO 3 is difficult to get right. I'm ok with either 1 or 2. Can we take inspiration from another spec or maybe JavaScript itself?

@bzbarsky
Copy link
Author

Fwiw, I agree that 3 is difficult to get right. Right now I think the spec is aiming for 2.

@tabatkins tabatkins removed the claimed label Feb 17, 2018
@tabatkins
Copy link
Member

Closing because the spec now clearly specifies 1.

@annevk
Copy link
Member

annevk commented Feb 22, 2018

I think it would help if you add an example of things seeming equal not being equal.

@annevk annevk reopened this Feb 22, 2018
@annevk
Copy link
Member

annevk commented Feb 23, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants