-
Notifications
You must be signed in to change notification settings - Fork 676
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
[css-values] Specify how to handle negative percentage basis in mathematical expressions #6298
Comments
See #4227 (comment):
So it's a bug if the implementation assumes that
|
I think reading the spec to the letter, we should never simplify percentages. However that's a bit of a hard one to fix with properties that only parse percentages because that requires preserving the calculation a lot longer than browsers are now. |
Hah, I mid-aired with oriol :) |
But properties that don't resolve percentages into another (non-number) type, like |
No, @emilio is right - the spec (mistakenly) never simplifies %s in min()/max(). It assumes they'll turn into another type, at which point they can simplify. I should fix that to specify that %s which would resolve to another type in the context shouldn't simplify away in this case, but %s which stand on their own can. |
That said, the OP is indeed invalid - the spec definitely does specify that you don't resolve a min() or max() in that case until simplification can change the %s into lengths, at which point you get the correct values. |
…at %s will always block simplification, and add a Note making the % behavior more explicit. #6298
I did just now add a small note making the behavior of percentages clearer, tho. |
This was indeed specified in the spec, and I just missed it. The spec makes sense as it is, but the added note is really helpful. |
Some properties like object-position can have a negative percentage basis.
This causes an issue where some browsers calculates/simplifies
clamp(100%, 50%, 0%)
to 100% ignoring the negative percentage basis, but solvesclamp(100%, 50% 0px, 0%)
to 50%. With a percentage basis of-100px
the original equation is equal toclamp(-100px, -50px, 0px)
which would solve to -50px. Solving the equation without accounting for the negative basis creates unexpected behaviour.(See https://bugzilla.mozilla.org/show_bug.cgi?id=1709018).
It would be helpful if the spec specified how to handle negative percentage basis in mathematical expressions https://drafts.csswg.org/css-values-4/#calc-func
The text was updated successfully, but these errors were encountered: