-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CSS Adjacent Sibling Combinator (+
) is causing some CSS to be erroneously removed
#9274
Comments
On my initial attempt at looking into this, I identified the bug as caused by this line
I managed to get a fix by creating a new function However, just as I was preparing a PR and a test case I realized that the bug isn't so much caused by the presence of the slot (it does play a part), but because of the surrounding container. In the reproduction REPL, if we removed the container div in the Focus.svelte file the css selector will then work as intended and be applied. In light of this I think this bug warrants a bit more investigation. I'd likely come back to this in a couple of days once I get some more time on my hands EDIT: without a container, the clause is guarded by |
@kelvinsjk -- I see your proposed fix (thank you!) has been open for a week. Is there anything I can do to help move it forward? |
Keep sibling selectors when dealing with slots/render tags/`svelte:element` tags fixes #9274
Keep sibling selectors when dealing with slots/render tags/`svelte:element` tags fixes #9274
Describe the bug
Vite/Svelte reports
Unused CSS selector ":global(p) + .focus" (Focus.svelte:23:0)
and removes the CSS when thep
in the example selector comes from the Focus.svelte file's<slot />
. This looks like it started in Svelte 3.27.0 and persists through 4.2.1 (latest).Oddly, adding an additional class avoids this:
:global(p) + .focus .extra
will apply in the same scenario that:global(p) + .focus
fails to.Also, at present, if
:global(p) + .focus
applies to an element where thep
exists within the Svelte file, it will also apply to thep
coming from the<slot />
, presumably because the CSS is "used" and not removed by the compiler. This was not the case in versions 3.27.0 - 3.32.1.Reproduction
The Adjacent Sibling Combinator through
<slot />
REPL shows a list that is missing its red border. You can use the links to easily change the Svelte version.<slot />
elements.<slot />
elements, even if another pair of elements match.<slot />
elements unless another pair of elements match.The current issue at the simplest I've found is the following:
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: