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

🐛 BUG: Invalid markup generates a runtime error #353

Closed
1 task
godefroi opened this issue Mar 30, 2022 · 7 comments
Closed
1 task

🐛 BUG: Invalid markup generates a runtime error #353

godefroi opened this issue Mar 30, 2022 · 7 comments
Assignees
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) help wanted Please help with this issue!

Comments

@godefroi
Copy link

godefroi commented Mar 30, 2022

What version of astro are you using?

0.25.4

What package manager are you using?

yarn

What operating system are you using?

Windows

Describe the Bug

I am seeing an error attempting to render a very simple template. Support thread here: https://discord.com/channels/830184174198718474/958787462606495804

Minimal example linked below.

<!-- this works -->
{Object.keys(importedAuthors).map(author => <p>
	<div>hello</div>
</p>)}

<!-- this does not work -->
{Object.keys(importedAuthors).map(author => <p>
	<div>{author}</div>
</p>)}

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-rztbls?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@tony-sull
Copy link

@natemoo-re any chance this one's hitting a corner case in the compiler?

@ryanfitzer
Copy link

@godefroi I was able to get your example working by wrapping the return value in a fragment instead of a <p>. Not sure why that works but a <p> doesn't.

@donovanchilders
Copy link

I was able to get the non-working example to work by changing the <div> to a <span>. W3 considers a <div> element inside of a <p> element as invalid HTML. I wonder if that's why it's failing to compile in Astro.

@ryanfitzer
Copy link

Looks like if the markup requires interpolation is invalid, the compiler fails. Seems that maybe static markup doesn't have the same compiler steps (validation step?) as dynamic markup.

@natemoo-re natemoo-re transferred this issue from withastro/astro Apr 5, 2022
@natemoo-re
Copy link
Member

natemoo-re commented Apr 7, 2022

Nice sleuthing, @ryanfitzer! I took a stab at this one and I'm struggling to untangle where this is going wrong, but it looks like you're correct that mixing invalid HTML with expressions is the culprit.

Somehow the trailing ) in the expression is getting dropped before we generate the JS for the Astro component, so where we should be printing )} we're instead printing }. That's the cause of that error message.

I'll keep working to track down a fix!

@natemoo-re natemoo-re changed the title 🐛 BUG: ERROR: Expected ")" but found "}" when rendering simple template 🐛 BUG: Invalid markup generates a runtime error Apr 21, 2022
@natemoo-re natemoo-re assigned natemoo-re and unassigned natemoo-re Apr 22, 2022
@natemoo-re
Copy link
Member

Related to #432

@natemoo-re natemoo-re added the help wanted Please help with this issue! label Jul 25, 2022
@Princesseuh Princesseuh added the - P4: important Violate documented behavior or significantly improves performance (priority) label Nov 12, 2023
@MoustaphaDev MoustaphaDev self-assigned this Dec 19, 2023
natemoo-re added a commit that referenced this issue Jan 4, 2024
@MoustaphaDev
Copy link
Member

MoustaphaDev commented Jan 16, 2024

I forgot to close this somehow, should've been closed by #921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) help wanted Please help with this issue!
Projects
None yet
Development

No branches or pull requests

7 participants