Skip to content

[css-nesting-1] Indenting of deeply nested rules is still only one level #7862

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
sesse opened this issue Oct 10, 2022 · 1 comment
Closed

Comments

@sesse
Copy link
Contributor

sesse commented Oct 10, 2022

There's an example from the nesting-parsing.html test:

main { & > section, & > article { & > header { color: green; } } }

As far as I understand the algorithm (which is defined in https://drafts.csswg.org/cssom-1/#serialize-a-css-rule, I believe—it seems to have been updated for nesting, and then a near-identical copy was pasted into the css-nesting-1 draft for CSSNestingRule), this should be serialized as:

main {
  & > section, & > article {
  & > header { color: green; }
}
}

This isn't optimal, by any stretch; not only is it hard to understand the nesting level of the innermost rule, but the second-to-last } also comes at an unexpected place. Could we perhaps have some sort of explicit string replacement? Or idea of nesting level? I don't know how these algorithms are usually defined to be as implementable as possible.

@tabatkins
Copy link
Member

Yes, the serialization algo for rules has been incredibly busted (not technically broken, just producing terrible output) for many, many years. You get the same result for nesting @media/@support/style rules today.

So this ends up being a dupe of #4828

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

2 participants