Sibling Combinator combined with :has can be improperly marked as unused

#14072

Development PRs

Issue

Solved
C
craig-jennings
Oct 31, 2024, 4:13 PM

Describe the bug

I've got some complex sibling combinator + :has css selectors that match the DOM but are reported as unused by Svelte. Through further testing, it appears that some trivial cases are incorrectly marked as unused.

Reproduction

  1. Open ./packages/svelte/tests/css/samples/has/input.svelte
  2. Add the following code to the bottom of the style block
x:has(+ c) {
  color: green;
}

x:has(~ c) {
  color: green;
}

Notice that these are valid selectors based on the given DOM structure

  1. Run the test. It now fails with 2 css_unused_selector errors. I've found that wrapping c in :global() seems to get rid of the errors, but I'm not sure if that should be required to get this selector working.

Logs

No response

System Info

Svelte Version - 5.1.6

Severity

annoyance

👍 2

Info

Closed at Mar 14, 2025, 9:44 PM
Assignees dummdidumm
Labels css
Milestone None