Skip to content

Newline in string prop treated differently if in curly braces #15554

Open
@timephy

Description

@timephy

Describe the bug

Given any child component taking a prop text: string.

<Component text={"A\nB"}></Component>
<Component text="A\nB"></Component>

results in:

A B
A\nB

To me this is very unexcepted. It broke my layout that depended on a \n.

I can see that syntax highlighting marks \n as "special" when in curly braces, so I could have noticed it.

However, the linting warning Unexpected mustache interpolation with a string literal value.eslint[svelte/no-useless-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) lead me to remove the curly braces.

Reproduction

https://svelte.dev/playground/a709bcd1203b4664ab2188c4434b8099?version=5.23.2#H4sIAAAAAAAAE3WRzWrDMBCEX2VZemjBxHdjG9Le8wLdHhRnHQTySkibJsb43Yv6ExMnvc5-M9pZTShmYKxwx2dnhcEKJI1WjhCiD6CRjfIBDrbvObKoG8H2mepO0Y2wj6bjhAX21nHC6n1CHUMOzAIWf_HbEDbpk51mbW8SP9I7L8qiCSusUxdt0JaElNQOwUeFNz8ELywKffQDEG7Kq_SbQkhSl4tZ6sWkfNFmItwSySvh3NaLvb0nr-ANhwXmKVYaTzwX_9Rdr3Vb-sH0vjo4I8eGUBPh9xk6L0lhyq_P0MBT_p_0_LLuG9ofpC7DatmP-QundUBE7gEAAA==

Logs

System Info

playground

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions