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

Extraneous whitespace around comments #1

Open
nonphoto opened this issue Jan 5, 2022 · 3 comments
Open

Extraneous whitespace around comments #1

nonphoto opened this issue Jan 5, 2022 · 3 comments

Comments

@nonphoto
Copy link

nonphoto commented Jan 5, 2022

Svelte preserves whitespace inside regular tags. HTML comments are stripped out by the compiler, but the whitespace around them is not, causing the component output to have extraneous newlines. This is an issue with pre tags and white-space: pre or pre-line in CSS. We should remove the comments, or at least include the whitespace inside the comment delimiters.

@hdoro
Copy link
Contributor

hdoro commented Feb 16, 2022

Hey Jonas, thank you for reporting! This is a known issue with Svelte's SSR preserving whitespace while DOM hydration correctly removes it - see issue n° 3168, which although closed hasn't been fixed.

I honestly don't know what approach to take, as manually removing the whitespace in our code is prone to error and makes the library code unreadable and hard to maintain. Also, we're using Prettier for automatic formatting, and it's set to format whitespace around the comments, not inside them.

All that said, I'm open to suggestions and am glad to hear your thoughts 😄

@el-schneider
Copy link

Hi there, is there any workaround for this? I'm running into this issue and especially with larger text the discrepancy between SSR and Client get's highly noticable.

@kiosion
Copy link
Contributor

kiosion commented Feb 14, 2024

Would Svelte's preserveWhitespace compiler option help with this? If the removal is inconsistent, setting it to true might at least keep it consistent between SSR & Hydration

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

4 participants