Skip to content

HTMLSlotElement.assign() should accept nodes already assigned to children of the host #12043

@Schommer475

Description

@Schommer475

What problem are you trying to solve?

Manual slot assignment exists as a mechanism for producing CEs that accept a dynamic number of slotted nodes, especially when each item needs to be wrapped in other elements. A common example is custom list elements, where each child needs to be wrapped in an li.

However, if another CE wants to include this custom list and allow its own consumers to populate it, it is currently not possible to do so simply by placing a slot within the tags of the custom list. The nodes assigned to the slot cannot currently be reassigned into separate slots within the list.

What solutions exist today?

The only solution currently available is for the consuming CE to also use manual slot assignment and to create a new slot element for each item it wants to forward to the list. This may, in turn, create a need for the CE's consumer to use manual slot assignment. And so on up the chain.

How would you solve it?

When an HTMLSlotElement is a direct child of a CE (one of its slottables) and the CE uses manual slot assignment, the CE should be able to take nodes assigned (directly or indirectly) to that slot and assign them to slots within its shadow tree, using HTMLSlotElement.assign(). This should have the effect of forwarding the nodes through the new slot, rather than actually reassigning them.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions