-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
subtract add don't act as expected in some cases #33953
Comments
Thanks for reporting! Would you mind providing a real example please, to help figure it out? I see your point but your examples are incorrect since our functions would have solved the Regardless, always providing parenthesis could break things (also I don't know which, just a possibility). I say we have two ways to handle this:
Not sure what's the best way for now, still thinking out loud. |
Please, notice that the second number is in A real word example - one that actually made me realize the problem. A have the
Now let's say:
That outputs:
which is perfectly correct. But if the size of the icon is expressed in
you get:
Witch is incorrect!!! So one expression outputs correct and incorrect values depending on the units of the variables - that's very misleading. It should output:
or
There's actually another way to tackle that problem - make the subtract function do the work. As far as I know you may use parentheses in calc however you want (to establish computation order when needed - see mdn page). Actually I think calc with calc is valid as well (though not necessary). |
Option a) seems a good idea to me! Changing the sign will very likely introduce new edge cases, seems more risky. |
The functions do not act as I would expect (as I think is intuitive) when the result of the add function is used as an argument for the subtract function.
Eg.
subtract(100%, add(1rem, 1em, false));
returns
calc(100% - 1rem + 1em)
I would expect
calc(100% - (1rem + 1em))
or
calc(100% - 1rem - 1em)
The text was updated successfully, but these errors were encountered: