compiler
compiler copied to clipboard
🐛 BUG: [AST] Fragments are moved inside conditional code
Describe the Bug
Using v0.1.0-next.4.
If I run prettier on this code:
<Fragment>
<span>bar</span>
{foo && <span>{foo}</span>}
</Fragment>
It becomes:
<Fragment>
<span>bar</span>
</Fragment>{foo && <span>{foo}</span>}
I was only using the fragment to try to work around a separate bug in the astro compiler, and I realize it's not really usually needed in this situation, but it was still unexpected that prettier would make this change.
Steps to Reproduce
Run prettier against code like this:
<Fragment>
<span>bar</span>
{foo && <span>{foo}</span>}
</Fragment>
and see that the Fragment is moved.
I checked this out. Probably a @astrojs/compiler bug.
JSX expression is determined to be outside <Fragment>.
https://stackblitz.com/edit/github-au6cvz-1j6mfg?file=src%2Fpages%2Findex.astro
@natemoo-re
This has been fixed in recent versions, so I'm going to close this one out!