withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
502 stars 59 forks source link

Parsing Error Results in "Cannot read properties of undefined (reading 'Symbol(astro:slot-string)')" #914

Open gvkhna opened 1 year ago

gvkhna commented 1 year ago

Astro Info

Using latest version on stackblitz

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Following in an Astro component <div class="text-zinc-500 before:content-['\0022'] after:content-['\0022']">Hello</div>

Causes the following error: Cannot read properties of undefined (reading 'Symbol(astro:slot-string)')

Minimal Repro Linked

Simply changing the snippet to <div class={text-zinc-500 before:content-['\0022'] after:content-['\0022']}>Hello</div> makes the parser/linter correctly flag that the syntax needs to be updated to octal sequence format ('\x022'). Etc. Otherwise the astro:slot-string error is opaque and not descriptive of the actual issue.

What's the expected result?

It should correctly parse without bracket tilde syntax {``}, and show the error that the classname needs to be updated with octal sequence format.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ashetc-21tni3?file=src%2Fcomponents%2FTest.astro

Participation

MoustaphaDev commented 11 months ago

This is caused by those octal characters being internally injected in template strings. We should escape them (and probably other characters that can break in template strings) in the compiler