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

Unnecessary space added for non-rendered {#if} block #15667

Open
bdpartridge opened this issue Apr 1, 2025 · 3 comments
Open

Unnecessary space added for non-rendered {#if} block #15667

bdpartridge opened this issue Apr 1, 2025 · 3 comments

Comments

@bdpartridge
Copy link

Describe the bug

An unnecessary space is included in the HTML output of elements that include an {#if} block that is not rendered.

Reproduction

https://svelte.dev/playground/hello-world?version=5.25.6#H4sIAAAAAAAAE5WRsU7DMBCGX-VkGFopSvaQVnToxsiGGVznolh1HMu-0qIoKw_AI_Ik2EkpjdoiMfr3_f99d9cxIxpkOVsfyAnwVkgEURE6UBVsdCu3LGGV0uhZ_tIxerexOgpBP3pX1qb-DTVFbSM8XtNlawgNhRhWeOmUpSU3nFRjW0fwpMwWKtc2wFmaxdfRydkDN0X26zCFHYwrA3jGrDwoI_WuxBL2NRqgGk8jxF_TEjg0JTos8xhQDD1rh9WCs5rI-jzL8CAaqzGVbcPZcj2-QIfKYqBappHGnoM81yFy7DAhukrxT4IYiM4I_SdK2C6FQpaT22Gf3LjS2VKnZ5p-3LiTRoIuoiYnJlhAJbTHBGStdBlG64N0b11r_Wx-cTYx-vshrnscN3Gyzub9oN-Fbf006L8-PrtMVX2MEheDvoaXUHqvTMnygaT_BuckIsrPAgAA

Logs

System Info

System:
  OS: macOS 15.3.2
  CPU: (12) arm64 Apple M2 Pro
  Memory: 2.44 GB / 32.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.14.0 - ~/projects/fwd/.gradle/nodejs/node-v20.14.0-darwin-arm64/bin/node
  npm: 10.7.0 - ~/projects/fwd/.gradle/nodejs/node-v20.14.0-darwin-arm64/bin/npm
  pnpm: 9.1.4 - ~/projects/fwd/.gradle/pnpm/pnpm-v9.1.4/bin/pnpm
Browsers:
  Chrome: 134.0.6998.166
  Edge: 134.0.3124.95
  Safari: 18.3.1
npmPackages:
  svelte: 5.22.5 => 5.22.5

Severity

annoyance

@brunnerh
Copy link
Member

brunnerh commented Apr 1, 2025

@bdpartridge
Copy link
Author

bdpartridge commented Apr 1, 2025

@brunnerh Looks like the relevant bit from the migration docs is this:

Whitespace between nodes is collapsed to one whitespace

That makes sense, but I'm surprised that logic applies to an {#if} block when it's not rendered. Should a node that's not in the DOM count as a node? Happy to close this issue if that's the case, but it might be worth clarifying this behavior somewhere in the docs at least.

@brunnerh
Copy link
Member

brunnerh commented Apr 1, 2025

Should a node that's not in the DOM count as a node?

Maybe not, though it looks like it currently does and changing it probably is not an option without a major version.

Regarding documentation, it would be nice to have a section on whitespace handling somewhere at the end of the basic markup section, especially since currently it only seems to be mentioned in the migration guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants