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

unexpected style when I use :where in global CSS #425

Open
saadeghi opened this issue Oct 22, 2021 · 2 comments
Open

unexpected style when I use :where in global CSS #425

saadeghi opened this issue Oct 22, 2021 · 2 comments

Comments

@saadeghi
Copy link

Describe the bug
When I add a PostCSS preprocessor to svletekit, below CSS code doesn't work anymore:

<style global>
.btn:where(.btn-primary,.btn-secondary){
  background-color: green;
}
</style>

To Reproduce

  1. Clone this: https://github.com/saadeghi/svelte-preprocess-postcss-bug
  2. npm install
  3. npm run dev
  4. now uncomment line 5 on svelte.config.js to disable the preprocess and npm run dev again to see expected style

Expected behavior

Expected CSS:

.btn:where(.btn-primary,.btn-secondary){
  background-color: green;
}

generated CSS:

.btn:where(.btn-primary),:global(.btn-secondary){
  background-color:green
}

Information about your project:
https://github.com/saadeghi/svelte-preprocess-postcss-bug

@kissge
Copy link

kissge commented Jun 6, 2022

+1.

This actually causes problems more often than one might think since popular packages like the-new-css-reset use :where.

Minimal repro for such cases is:

<style lang="sass" global>
  @use 'the-new-css-reset/css/reset'
</style>

@ivanhofer
Copy link

The bug is located in this function: https://github.com/sveltejs/svelte-preprocess/blob/main/src/modules/globalifySelector.ts#L11

The Regex does not account for more modern :where, :not and :ìs selectors

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

3 participants