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

Incorrect compilation of nested CSS appends type selector after subclass selectors #489

Closed
evanw opened this issue May 13, 2023 · 2 comments

Comments

@evanw
Copy link

evanw commented May 13, 2023

Input:

.foo {
  > &a,
  + &b {
    color: red;
  }
}

Output from Lightning CSS (playground link):

.foo > .fooa, .foo + .foob {
  color: red;
}

Expected output:

.foo > a.foo, .foo + b.foo {
  color: red;
}

The problem is that the type selector must be prepended to avoid creating an invalid compound selector, but Lightning CSS appends it instead. Other similar problem cases to .foo are #foo, :foo, and even foo.

I recently fixed a similar issue in esbuild and Lightning CSS has the same bug, so I figured I'd report it here too. FWIW my fix was a hack: I just moved the & token after the type selector when converting the nested selector to a token stream so that the later substitution of & ends up in the right place (so &a is basically changed to a& internally). I didn't do any big changes to token substitution itself such as re-parsing the token stream.

@evanw
Copy link
Author

evanw commented May 15, 2023

Ah sorry, I wasn't aware that they changed the syntax again. My mistake.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
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

No branches or pull requests

2 participants