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

Elements not rendered in Fragment when using ternary #9997

Closed
1 task
ferencalmasi opened this issue Feb 6, 2024 · 1 comment
Closed
1 task

Elements not rendered in Fragment when using ternary #9997

ferencalmasi opened this issue Feb 6, 2024 · 1 comment
Labels
needs triage Issue needs to be triaged

Comments

@ferencalmasi
Copy link

Astro Info

Astro                    v4.3.2
Node                     v18.18.0
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

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

No response

Describe the Bug

Using ternary operators inside a Fragment breaks the rendering of adjacent elements:

<Fragment>
  <h1>title</h1>
  {true ? <h2>sub title</h2> : <strong>strong tag</>}
</Fragment>

In the above example, the h1 will not be rendered. It'll only be rendered if:

  • Using two separate logical AND operators inside the Fragment
  • Nesting the condition inside another Fragment

This functionality was working as expected in previous versions (e.g. 2.4.5).
Please see repro for examples.

What's the expected result?

  • Elements inside a Fragment without conditions should be rendered
  • Elements inside a Fragment with conditions should be rendered based on the evaluation of the condition, without the need of nesting Fragment.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-cwjduy?file=src%2Fpages%2Findex.astro&title=Astro%20Starter%20Kit:%20Blog

Participation

  • I am willing to submit a pull request for this issue.
@MoustaphaDev
Copy link
Member

Hey thanks for taking the time to report! We're tracking the issue in withastro/compiler#955 and I made a PR that should fix it in withastro/compiler#963, so I'll close this as duplicate.

@MoustaphaDev MoustaphaDev closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants