Skip to content
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-5] should 'calc-size(0)' work? #10354

Open
dbaron opened this issue May 20, 2024 · 2 comments
Open

[css-values-5] should 'calc-size(0)' work? #10354

dbaron opened this issue May 20, 2024 · 2 comments

Comments

@dbaron
Copy link
Member

dbaron commented May 20, 2024

In https://issues.chromium.org/341564374 @yisibl pointed out that calc-size(0) doesn't work. I think this matches the current spec which defines the behavior to work like calc(), where it was intentional that calc(0) doesn't work.

I think despite the parallels with calc() we may want to consider making calc-size(0) work correctly, because:

  • calc-size() is explicitly for lengths only so there's less concern about unit algebra making sense
  • it would be nice to preserve the principle that "wrap an animation endpoint in calc-size()" works in general, and 0 is one of the most common length animation endpoints.
@Loirooriol
Copy link
Contributor

To clarify, this is about unitless lengths. calc(0) works fine as an <integer>.

@tabatkins
Copy link
Member

Yes, I think allowing a bare 0 is fine; as you say, we have the necessary context to infer the type (the calculation must be a length).

We probably want to do it as a grammar branch, so only a literal 0 with nothing else works. (Such a calculation would otherwise be invalid since it would type as <number>, so this is safe.) If the calculation is any more complex than that, we continue to treat it as a number.

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

3 participants