Skip to content

🐛 BUG: regression in handling of string literal props #89

Description

@delucis

What version of @astrojs/compiler-rs are you using?

0.3.1

What package manager are you using?

pnpm

What operating system are you using?

macOS

Describe the Bug

With @astrojs/compiler is was possible to use escaped characters like \n in a string prop and have that show up when used:

<MyComponent prop="Example\nwith\nnew\nlines" />
---
// MyComponent.astro
---
<p>{Astro.props.prop}</p>

Would render as:

<p>Example
with
new
lines</p>

With @astrojs/compiler-rs the same usage treats the \ as a literal backslash and renders:

<p>Example\nwith\nnew\nlines</p>

Probably unusual usage but we were depending on this in the astro.new repo here: https://github.com/withastro/astro.new/blob/d15d68e5562e524eed798039cb1cceacb43f6e7a/src/components/ResourceCard.astro#L41 (Using white-space: pre-line; in the CSS there means the \n were respected and displayed, but when updating to Astro 7 and the new compiler I spotted this regression.)

Notably, the compiler does handle these cases as expected:

<Component prop={"One,\ntwo,\nthree."} />

<Component prop={`One,\ntwo,\nthree.`} />

<Component prop={`One,
two,
three.`} />

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-mndctqis?file=src%2FComponent.astro,src%2Fpages%2Findex.astro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions