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

Child combinator (>) in :has sometimes vanishes when transpiling nested css #3877

Closed
malte-laukoetter opened this issue Aug 14, 2024 · 1 comment
Labels

Comments

@malte-laukoetter
Copy link

malte-laukoetter commented Aug 14, 2024

When transpiling the following css using --supported:nesting=false the child combinator within the :has vanishes

.a :has(> .c) {
  .b & {
    background-color: green;
  }
}

result:

.b :is(.a :has(.c)) {
  background-color: green;
}

expected result:

.b :is(.a :has(>.c)) {
  background-color: green;
}

esbuild playground: https://esbuild.github.io/try/#YgAwLjIzLjAALS1zdXBwb3J0ZWQ6bmVzdGluZz1mYWxzZQBlAGVudHJ5LmNzcwAuYSA6aGFzKD4gLmMpIHsKICAuYiAmIHsKICAgIGJhY2tncm91bmQtY29sb3I6IGdyZWVuOwogIH0KfQ

see also: vuejs/core#11613

@ybouane
Copy link

ybouane commented Feb 3, 2025

I get a similar issue with this:
https://esbuild.github.io/try/#YgAwLjI0LjIALS1zdXBwb3J0ZWQ6bmVzdGluZz1mYWxzZQBlAGVudHJ5LmNzcwAuYSB7CiAgOmhhcyg+JikgewogICAgYmFja2dyb3VuZDpyZWQ7CiAgfQp9

Input:

.a {
  :has(&) {
    background:red;
  }
}

Give the correct output:

:has(.a) {
    background:red;
  }

But this input:

.a {
  :has(>&) {
    background:red;
  }
}

Give the incorrect output:

.a :has(>.a) {
    background:red;
  }

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

No branches or pull requests

3 participants