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

"&" selector not preserved inside @scope #700

Open
axyz opened this issue Mar 14, 2024 · 1 comment
Open

"&" selector not preserved inside @scope #700

axyz opened this issue Mar 14, 2024 · 1 comment

Comments

@axyz
Copy link

axyz commented Mar 14, 2024

Hi, I noticed an issue with @scope at rules.

When the & selector is used, it does not get preserved and it gets substituted with a :scope selector

can be verified here

Beside being slightly longer for the sake of minification, the selector should be preserved as it is (either & or :scope) due to the different impact on specificity.

Additionally & supports reuse in the same selector.

e.g.

@scope(.foo) {
  & &  {
    --color: yellow;
  }
}

this is valid in CSS, but using lightningcss it outputs

@scope (.foo) {
  :scope :scope {
    --color: yellow;
  }
}

that is invalid. playground here

@devongovett
Copy link
Member

Hmm, I think this isn't really a valid configuration. You've set the target to an old version of chrome that doesn't support @scope or nesting. And since scope is only supported in browsers that also support nesting, this won't actually happen. If you raise your target to a newer version, it works correctly. See example

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