Skip to content

[css-values] toggle() for shorthands is not forward compatible #6764

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

Open
Loirooriol opened this issue Oct 26, 2021 · 3 comments
Open

[css-values] toggle() for shorthands is not forward compatible #6764

Loirooriol opened this issue Oct 26, 2021 · 3 comments

Comments

@Loirooriol
Copy link
Contributor

Loirooriol commented Oct 26, 2021

https://drafts.csswg.org/css-values/#funcdef-toggle

If toggle() is used on a shorthand property, it sets each of its longhands to a toggle() value with arguments corresponding to what the longhand would have received had each of the original toggle() arguments been the sole value of the shorthand.

Let's consider display: toggle(block, flow-root, inline).

Right now, display is a longhand property, so we have:

  • block flow -> block flow-root
  • block flow-root -> inline flow
  • anything else -> block flow

But it seems likely that we will want to convert display into a shorthand. Then, the example will become

display-outside: toggle(block, block, inline);
display-inside: toggle(flow, flow-root, flow);

Due to short-circuiting, that's equivalent to

display-outside: block;
display-inside: toggle(flow, flow-root);

Which behaves like

  • block flow -> block flow-root
  • anything else -> block flow
@fantasai
Copy link
Collaborator

@mirisuzanne recently proposed using @container style queries to solve the use cases of toggle(), so maybe it makes sense to do that and drop toggle() entirely.

@Loirooriol
Copy link
Contributor Author

If toggle() can be replaced with something else then it's fine, but this issue doesn't mean that it's unsalvageable.

I guess toggle() in a shorthand should set the longhands to a pending-toggle-resolution internal value, that would serialize as empty string and cascade as normally. At computed value time we would resolve that by taking the shorthand, and evaluating it to each of the values in toggle(). If all longhands would have the same computed value as the parent element, then it's a match. Then we pick the corresponding longhand component of the next toggle value.

@tabatkins
Copy link
Member

Ah, that's a great example, and definitely demonstrates the current spec text as being somewhat broken.

I agree that leaning on the identical solution we have for variables is probably what we'd have to do.

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