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

Populating named slots in a loop gives error: Expected ";" but found ":" #724

Open
1 task done
OscarHagman opened this issue Jan 26, 2023 · 1 comment · Fixed by #933
Open
1 task done

Populating named slots in a loop gives error: Expected ";" but found ":" #724

OscarHagman opened this issue Jan 26, 2023 · 1 comment · Fixed by #933
Assignees
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)

Comments

@OscarHagman
Copy link

What version of astro are you using?

2.0.2

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

When populating named slots in a loop it throws an error that isn't very useful. It also points to a row in the code that doesn't exist (points to row 33 when the file only has 13 rows). It works fine when only using one of the named slots, however if you use curly brackets {} in the map function to make it multi-lined it won't display the content (doesn't throw any errors with curly brackets)

Example component:

<section>
  <div class="slot-1-container">
    <slot name="1" />
  </div>
  <div class="slot-2-container">
    <slot name="2" />
  </div>
</section>

And when you import it:

---
import Test from "../components/Test.astro"

const data = [
  { a: "this", b: "is" },
  { a: "a", b: "test" },
]
---

<Test>
  {data.map((d) => <p slot="1">{d.a}</p><p slot="2">{d.b}</p>)}
</Test>

Example with curly brackets:

<Test>
  {data.map((d) => {
    <p slot="1">{d.a}</p>
  })}
</Test>

Link to Minimal Reproducible Example

https://codesandbox.io/p/sandbox/cool-architecture-8hf06e?file=%2Fsrc%2Fpages%2Fwithout-curly-brackets.astro&selection=%5B%7B%22endColumn%22%3A8%2C%22endLineNumber%22%3A12%2C%22startColumn%22%3A8%2C%22startLineNumber%22%3A12%7D%5D

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp transferred this issue from withastro/astro Feb 8, 2023
@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly improves performance (priority) label Jun 27, 2023
@MoustaphaDev MoustaphaDev self-assigned this Dec 20, 2023
@MoustaphaDev
Copy link
Member

Reopening this as we've reverted the fix made in #963, due to unexpected regressions that it caused.

@MoustaphaDev MoustaphaDev reopened this Feb 6, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 6, 2024
@MoustaphaDev MoustaphaDev removed the needs triage Issue needs to be triaged label Feb 12, 2024
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)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants