Skip to content

Slot let variables not accessible on slotted element root #4173

@Crisfole

Description

@Crisfole

In the following abbreviated components I'd expect to have access to foo in the h1 class attribute. But instead it's only accessible inside the slotted element content.

Parent

<Child {baz}>
  Content
  <h1 slot=foobar let:foo class='foobar-{foo.type}'>{foo.title}!</h1>
  <!--  Unexpected behaviour is here - - ^            ^- - - This works fine -->
</Child>

Child

<section class=child>
  <slot name=foobar foo={makeFoo(baz)} />
  {@html baz.content}
</Child>

I'd like the above example to work, with slot let variables in scope at the root slotted element

Alternatives to this include:

  • Wrapping in a dummy element. (Yuck)
  • bind:this and manually setting the attributes I want later. (Ulcer inducing)

This is pretty important for slotting tables: if you can't use data from the dataset to add attributes to slotted rows or cells you're missing something pretty darn important...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions