Skip to content

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

@craig-jennings

Description

@craig-jennings

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

Metadata

Metadata

Assignees

Labels

cssStuff related to Svelte's built-in CSS handling

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions