Open
Description
Describe the bug
When using conditionals in Svelte the result leaves empty comments inside the node. Since comments are considered childNodes this breaks the CSS selector :empty
.
We could use :not(:has(*))
as a workaround but the css output looks like this:
ul.svelte-vewu36:not(:has(/* (unused) **/)) { ... }
That said, I'd prefer not use use :not(:has(*))
since it's very inefficient.
I've also tried setting preserveComments=false
in my compiler options but it doesn't seems to do anything (in development anyway). Perhaps this has re-emerged as an issue: #4730 ?
Reproduction
https://svelte.dev/playground/d1989f455149482ca0d9202e915b743f?version=5.1.16
https://jsfiddle.net/jwerre/pcqt215b/10/
System Info
System:
OS: macOS 15.0.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.21 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.18.0 - /opt/homebrew/bin/node
Yarn: 1.22.22 - ~/.npm-global/bin/yarn
npm: 10.8.2 - /opt/homebrew/bin/npm
Browsers:
Chrome: 130.0.6723.117
Edge: 117.0.2045.40
Safari: 18.0.1
Severity
annoyance