compiler icon indicating copy to clipboard operation
compiler copied to clipboard

🐛 BUG: [AST] Fragments are moved inside conditional code

Open IanVS opened this issue 3 years ago • 1 comments

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.

IanVS avatar May 04 '22 15:05 IanVS

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

ota-meshi avatar Jun 01 '22 11:06 ota-meshi

This has been fixed in recent versions, so I'm going to close this one out!

natemoo-re avatar Nov 16 '22 14:11 natemoo-re