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

Top-level pseudo selector not giving correct output #159

Open
daanvosdewael opened this issue Jul 15, 2024 · 2 comments
Open

Top-level pseudo selector not giving correct output #159

daanvosdewael opened this issue Jul 15, 2024 · 2 comments

Comments

@daanvosdewael
Copy link

When using the plug-in with the following CSS:

:where(.foo) {
  color: #000;

  &__bar {
    font-size: 1rem;
  }
}

The output currently is this:

:where(.foo) {
  color: #000;
}

:where(.foo)__bar {
  font-size: 1rem;
}

I get that the logic is supposed to be putting __bar at the end of the & parent, but in this case I would expect the following instead:

:where(.foo) {
  color: #000;
}

:where(.foo__bar) {
  font-size: 1rem;
}

Is there a way to make this happen?

For context, I'm using this setup to make BEM-style selectors that can easily be overridden due to the :where selector that brings the specificity down to 0.

@ai
Copy link
Member

ai commented Jul 15, 2024

It looks too complicated to me.

If you can sent PR with simple and easy-to-maintain code, we can add this feature.

@daanvosdewael
Copy link
Author

I wouldn't know where to begin to fix this if I'm honest 😅 I could write you a test, but that is the easy part hahah.

For now I have a workaround that is a little cumbersome, but I'll put it up here for others that stumble on this issue in the future:

.foo {
  :where(&) {
    color: #000;
  }

  &__bar {
    :where(&) {
      font-size: 1rem;
    }
  }
}

Will yield the following:

:where(.foo) {
  color: #000;
}

:where(.foo__bar) {
  font-size: 1rem;
}

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