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

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

Open
craig-jennings opened this issue Oct 31, 2024 · 1 comment
Assignees
Labels
css Stuff related to Svelte's built-in CSS handling

Comments

@craig-jennings
Copy link
Contributor

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

@dummdidumm dummdidumm added the css Stuff related to Svelte's built-in CSS handling label Nov 2, 2024
@dummdidumm dummdidumm self-assigned this Nov 2, 2024
@thebjorn
Copy link

thebjorn commented Nov 4, 2024

Here is a REPL for a common use case:

<div class="form-field">
	<label for="a">label</label>
	<input id="a" type="text" required>
</div>

<style>
	label:has(+ [required])::after {
		content: '*';
	}
</style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css Stuff related to Svelte's built-in CSS handling
Projects
None yet
Development

No branches or pull requests

3 participants