Skip to content

Add support for dynamic <slot> names #4207

Open
@nolanlawson

Description

@nolanlawson

Developers would like to be able to have dynamic <slot> names:

<!-- x-slottable -->
<template>
  <slot name={dynamic}></slot>
</template>
<!-- x-slotter -->
<template>
  <x-slottable>
    <div slot={dynamic}></slot>
  </x-slottable>
</template>

This is currently disallowed by our compiler (Error: LWC1076: Name attribute on slot tag can't be an expression.). But there's nothing in native shadow DOM that inherently disallows this; we could trivially require it there.

In fact, you can already achieve this in native shadow DOM by doing manual DOM manipulation, or cheating by using lwc:spread.

One question is whether we'd want to support this in synthetic shadow DOM (probably not) or light DOM (maybe).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions