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

White space escape characters are written into HTML when spread is used with SSR #4240

Closed
jesseskinner opened this issue Jan 10, 2020 · 3 comments · Fixed by #4247
Closed
Labels

Comments

@jesseskinner
Copy link
Contributor

jesseskinner commented Jan 10, 2020

Describe the bug
When new lines and tabs are used in attributes, then run through SSR, they end up written into the HTML, eg. <div class="\none\ntwo\n"></div>. This breaks the class name and can cause a FOUC with Sapper, and would completely break rendering of HTML-only static-generated pages.

Logs
N/A

To Reproduce

REPL: https://svelte.dev/repl/80b8863b778c4b608537a98fb811de43?version=3.16.7

If you download the REPL, change to generate:'ssr' and then console.log(App.render()), you get

<div class="
	white
	space
">A</div>

<div class="\n\twhite\n\tspace\n">B</div>

<div class="white\nspace">C</div>

Expected behavior
I would expect the white space to be rendered into the HTML as white space characters, like the first <div> above.

Stacktraces
N/A

Information about your Svelte project:

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)
    N/A

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)
    Arch Linux

  • Svelte version (Please check you can reproduce the issue with the latest release!)
    3.16.7

  • Whether your project uses Webpack or Rollup
    Rollup

Severity
HTML-only web pages would be severely broken by this bug, and it may not be obvious during development. Sapper sites will have a FOUC.

Additional context
I came across this bug by running into a bug causing a FOUC when I was using Svelte Material UI:
hperrin/svelte-material-ui#66

@Conduitry Conduitry added the bug label Jan 10, 2020
@jesseskinner
Copy link
Contributor Author

I think I'll try fixing it tomorrow on my Twitch stream, at least by adding some failing test cases if not actually fixing it.

jesseskinner added a commit to jesseskinner/svelte that referenced this issue Jan 10, 2020
jesseskinner added a commit to jesseskinner/svelte that referenced this issue Jan 10, 2020
…with concatenation of double quotes before and after the value. Fixes sveltejs#4240
@jesseskinner jesseskinner mentioned this issue Jan 10, 2020
4 tasks
@jesseskinner
Copy link
Contributor Author

@Conduitry I think I've found a solution.

@Conduitry
Copy link
Member

Thanks! Your fix has been published in 3.17.0.

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

Successfully merging a pull request may close this issue.

2 participants