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-4] "Simplify a calculation tree" doesn't return in all paths #11572

Open
AtkinsSJ opened this issue Jan 27, 2025 · 0 comments · May be fixed by #11573
Open

[css-values-4] "Simplify a calculation tree" doesn't return in all paths #11572

AtkinsSJ opened this issue Jan 27, 2025 · 0 comments · May be fixed by #11573

Comments

@AtkinsSJ
Copy link
Contributor

Based on the current css-values-4 simplify a calculation tree algorithm.

Specifically, if root is an operator node that is not a calc-operator node, and there is not enough information to compute its operation, then we end up reaching the end of the algorithm.

For example, if we enter the algorithm with root being min(1em + 2em, 10px), and not enough information to convert an em to px:

  • Steps 1 and 2 are skipped.
  • Step 3, "At this point, root is an operator node. Simplify all the calculation children of root." will simplify the sum node. So we get min(3em, 10px).
  • Step 4 does not have enough information to compute the min() operation, so it's skipped.
  • No subsequent step handles a min() operation, so we go off the end of the algorithm.

I think the solution is just to add a catch-all final step of "Return root." I'll submit a PR momentarily.

Alternatively, step 4 could gain an "Otherwise, return root" substep. But this is complicated by the requirement to fall through to step 5 for Min and Max nodes. Personally I prefer the simpler solution.

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

Successfully merging a pull request may close this issue.

1 participant