Skip to content

[@astrojs/lit] Slotted content is wrapped in <astro-slot> elements which breaks native slot functionality #5475

@ba55ie

Description

@ba55ie

What version of astro are you using?

1.16.11

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

None

What package manager are you using?

npm

What operating system are you using?

Windows, Linux

Describe the Bug

When using a client directive or the Class constructor for Lit Web Components an extraneous astro-slot element is created which interferes with styling of content within native slot elements.

When looking at the example MyCard elements, the first two don't get the correct css styling. The h1 should be hotpink and the footer text should be gray.

The added <astro-slot><h1>...</h1></astro-slot> element interferes with the styling, because the ::slotted selector only supports compound top-level selectors: https://developer.mozilla.org/en-US/docs/Web/CSS/::slotted

There are also some render issues. I also tried the is:raw directive, but that doesn't seem to make a difference.

image

image

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wqbjru?file=src/components/my-card.ts

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions