You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using TailwindCSS with the :global() directive and dark mode variants (dark:) in Svelte 5, I encountered an issue where the generated CSS selectors are incorrect. Instead of generating :global(div:where(...)), it produces :global(div):where(...), causing unexpected behavior and warnings.
Steps to Reproduce:
Created a new Svelte 5 project with TailwindCSS.
In app.html I added the data-color-theme attribute:
<divclass="markdown">
{@html`<div> <code>All background colors are expected to be blue, red should not be visible</code> </div>`}
</div>
<stylelang="postcss">
.markdown { :global(div) {@apply bg-red-500 p-10;/* This line generates incorrect CSS which breaks styling and throws warnings during build */@apply dark:bg-blue-500; }/* WORKAROUND: These styles work as expected */ :global(code:where([data-color-theme="dark"], [data-color-theme="dark"] *)) {@apply bg-blue-500; } }
</style>
Build the project using Svelte 5's build process.
Expected Behavior:
The :global() directive should generate CSS selectors with the correct syntax, i.e., :global(div:where(...)).
Actual Behavior:
The generated CSS selector is incorrect:
Describe the bug
While using TailwindCSS with the
:global()
directive and dark mode variants (dark:
) in Svelte 5, I encountered an issue where the generated CSS selectors are incorrect. Instead of generating:global(div:where(...))
, it produces:global(div):where(...)
, causing unexpected behavior and warnings.Steps to Reproduce:
app.html
I added thedata-color-theme
attribute:Expected Behavior:
The
:global()
directive should generate CSS selectors with the correct syntax, i.e.,:global(div:where(...))
.Actual Behavior:
The generated CSS selector is incorrect:
This incorrect selector causes unexpected behavior and generates warnings during the build process.
Additional Information:
I'm currently migrating a project from Svelte 4 to Svelte 5 which has this pattern and worked fine before the migration.
Looks like this bug is closely related to this one: #10513
I tried some of the suggestions on that issue but couldn't solve the problem on my end.
Reproduction
https://github.com/fmaclen/tailwind-global-css-bug
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: