fix: handle sibling combinators within :has
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.
./packages/svelte/tests/css/samples/has/input.svelte
style
blockx:has(+ c) {
color: green;
}
x:has(~ c) {
color: green;
}
Notice that these are valid selectors based on the given DOM structure
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.No response
Svelte Version - 5.1.6
annoyance
We didn't collect sibling elements of a given element to then check the :has
selectors. This adds the logic for that. Fixes #14072
feat:
, fix:
, chore:
, or docs:
.pnpm test
and lint the project with pnpm lint
Latest commit: 9210016
The changes in this PR will be included in the next version bump.
Name | Type |
---|---|
svelte | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
pnpm add https://pkg.pr.new/svelte@14213
We didn't collect sibling elements of a given element to then check the :has
selectors. This adds the logic for that. Fixes #14072