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

False positive "Unused CSS selector" on :global():has() #14910

Closed
7nik opened this issue Jan 6, 2025 · 3 comments · Fixed by #15140
Closed

False positive "Unused CSS selector" on :global():has() #14910

7nik opened this issue Jan 6, 2025 · 3 comments · Fixed by #15140

Comments

@7nik
Copy link
Contributor

7nik commented Jan 6, 2025

Describe the bug

Selector like :global(.parent):has(.component), which points to an external element but also refers to a component's one, is marked as unused.

Reproduction

Example version 5.16.2

Logs

No response

System Info

Version 5.16.2

Severity

annoyance

@petergoes
Copy link

I am facing the same issue, when migrating our codebase from Svelte 4 to Svelte 5.

Because of the size of our codebase, the severity of this issue exceeds annoyance for us. It prevents us from upgrading all together.

I only upgraded the svelte version, I did not converted anything to runes just yet.

My reproduction

@7nik
Copy link
Contributor Author

7nik commented Jan 28, 2025

That looks correct to me: the App component doesn't have any .card elements, and it can be fixed by

-	div :global(.card-list) {
+	div :global .card-list {

or wrapping :has() with another :global().

@petergoes
Copy link

Ow wauw, I completely missed the :global syntax (as in not function like). Thanks.

dummdidumm pushed a commit that referenced this issue Jan 30, 2025
Fixes #14910

The issue occurs only when :has() targets at a component's root element and because include_self is false.
I came to the conclusion that this is the same case as :root:has(.scoped).
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

Successfully merging a pull request may close this issue.

2 participants