Skip to content

Astro component with table and slot wrongly parsed #12300

@mb21

Description

@mb21

Astro Info

Astro                    v4.16.7
Node                     v20.12.2
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/solid-js

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

No response

Describe the Bug

The following page:

---
import MailLayout from '../components/MailLayout.astro'

const name = 'foo'
---

<MailLayout>

  <tr>
    <td>
      <a href="/foo" target="_blank">
        {name}
      </a>
    </td>
  </tr>

  <div slot="footer">
    Footer
  </div>
</MailLayout>

that uses components/MailLayout.astro:

---
---

<main>
  <slot />
</main>

<footer>
  <slot name="footer" />
</footer>

Is converted to the following HTML, which is obviously wrong:

<body>
    <main>
        <a href="/foo" target="_blank"> foo </a>
        <a href="/foo" target="_blank">
            <div slot="footer">
                Footer
            </div>
        </a>
    </main>
    <footer></footer>
</body>

What's the expected result?

Correct HTML with non-empty <footer> and not duplicated link.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-h3l48b?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions