Skip to content

Nesting transform is incorrect? #67

@evanw

Description

@evanw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions