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

support CSS nesting syntax (with the & selector) #1283

Closed
thescientist13 opened this issue Sep 20, 2024 · 0 comments · Fixed by #1281
Closed

support CSS nesting syntax (with the & selector) #1283

thescientist13 opened this issue Sep 20, 2024 · 0 comments · Fixed by #1281
Labels
Milestone

Comments

@thescientist13
Copy link
Member

Summary

As far as nesting goes, it seems with both CSS Tree versions 2.x and 3.x work both with and without the &

<html>
  <head>
    <style>
      h2 {
        & span {
          color: red;
        }
      }
      
      h3 {
        span {
          color: blue;
        }
      }
    </style>
  </head>
  <body>
    <h2>This is the second heading that <span>should be red</span>.</h2>
    <h3>This is the second heading that <span>should be blue</span>.</h3>
  </body>
</html>

But, we get parse errors for the non & styles

Parse error: Colon is expected
    6 |
    7 |h3 {
    8 |  span {
--------------^
    9 |    color: blue;
   10 |  }

And the & styles comes out the other side missing the &

h2{ span{color:red}}h3{span {
    color: blue;
  }}

Screenshot 2024-09-14 at 8 35 11 AM
Screenshot 2024-09-14 at 8 34 59 AM

Details

Looks we there is a NestedSelector we can grab from CSS Tree to preserve the &

For the non & use case, seems like there is an open issue for that - csstree/csstree#268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant