Skip to content

[css-color-5] Out of range percentages in color-mix() seem to be implemented incorrectly in every major browser? #10477

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
LeaVerou opened this issue Jun 20, 2024 · 2 comments
Labels
css-color-5 Color modification

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Jun 20, 2024

The spec says that percentages outside [0%, 100%] make color-mix() invalid:

Percentages are required to be in the range 0% to 100%. Negative percentages are specifically disallowed.

However, in my testing, browsers seem to handle this differently based on whether the percentage is the result of a calculation or not, which seems absurd.
Instead of IACVT, they seem to clamp the result of the calculation to [0%, 100%].

image

However, given the fact that they’re all interoperable about this behavior, I wonder if I’m missing something?

@LeaVerou LeaVerou added the css-color-5 Color modification label Jun 20, 2024
@cdoublev
Copy link
Collaborator

You are missing this:

Parse-time range-checking of values is not performed within math functions, and therefore out-of-range values do not cause the declaration to become invalid. However, the value resulting from a top-level calculation must be clamped to the range allowed in the target context.

I think this behavior is mainly needed for relative dimensions (whose computed value may or may not be out of range).

@LeaVerou
Copy link
Member Author

Thanks! I’ll close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-color-5 Color modification
Projects
None yet
Development

No branches or pull requests

2 participants