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

Nesting transform is incorrect? #67

Closed
evanw opened this issue Jan 20, 2022 · 2 comments
Closed

Nesting transform is incorrect? #67

evanw opened this issue Jan 20, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@evanw
Copy link

evanw commented Jan 20, 2022

First, thank you for making this library. It's wonderful to see something like this, especially as an independent library, and I know how much work it is to make one of these.

I looked into transforming CSS nesting in esbuild recently and I was wondering how this library does it. I think I've found a case where this implementation deviates from the CSS nesting specification:

.foo .bar {
  &div { color: red }
}

This library transforms that into this code (live link):

div.foo .bar{color:red}

However, if I'm reading it correctly the specification says this should be transformed into the following code instead (in this section):

div:is(.foo .bar){color:red}

These two code snippets are not equivalent. For example, the following HTML is supposed to render as black if the specification is followed, but renders as red with the output from this library:

<div class="foo">
  <span class="bar">stuff</span>
</div>

Just letting you know about this edge case. I don't need this edge case to work since I'm not using your library myself. Feel free to do what you want with this issue.

Potentially related: #19

@devongovett
Copy link
Member

Yeah you are correct. Another way to do it would be .foo .bar:is(div) or .foo div.bar. There's some complicated logic to deal with type selectors, which must always come first in a selector, so probably a bug in that somewhere. I'll look into it soon. Thanks for the report!

@devongovett devongovett added the bug Something isn't working label Jan 20, 2022
@cyjake
Copy link
Contributor

cyjake commented Jun 1, 2022

@devongovett :is() is way too new (Chrome >= 88) a syntax to use when targeting browsers like Chrome 55, which is still quite common among android devices in China.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants