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

Escaped line breaks \n do not work in attributes #7848

Closed
SystemParadox opened this issue Sep 9, 2022 · 2 comments
Closed

Escaped line breaks \n do not work in attributes #7848

SystemParadox opened this issue Sep 9, 2022 · 2 comments

Comments

@SystemParadox
Copy link

SystemParadox commented Sep 9, 2022

Describe the bug

If you use a line break like \n in an attribute like title, you get a literal \n in the tooltip output instead of a newline.

It works correctly if you use a variable from the script tag or if you use an actual line break in the source code, but if you write \n you get a literal \n. See the attached REPL:

<script>
	let title = 'foo\nbar';
</script>
<h1 {title}>Variable</h1>
<h1 title='foo\nbar'>Inline escaped</h1>
<h1 title='foo
bar'>Inline real</h1>

Works correctly for "Variable" and "Inline real", but not "Inline escaped".

Reproduction

https://svelte.dev/repl/73ceb4ac83b74c33a7d24cafdc81434a?version=3.50.1

Logs

No response

System Info

System:
    OS: Linux 5.4 Linux Mint 20.3 (Una)
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
    Memory: 3.51 GB / 15.56 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 105.0.5195.52
    Firefox: 104.0.1

Severity

annoyance

@Conduitry
Copy link
Member

This is how HTML behaves and is the intended behavior in Svelte. \n in an attribute value in HTML does not mean a newline.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2022
@SystemParadox
Copy link
Author

SystemParadox commented Sep 9, 2022

Oh. That does make sense although is a bit surprising. May I suggest noting this in the docs?

Note to self: title={'foo\nbar'} avoids this issue.

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