Skip to content

Compiler shouldn't allow mixed of named slots and default slots #4561

Closed
@tanhauhau

Description

@tanhauhau

Is your feature request related to a problem? Please describe.
When using named slots and default slots together, it is a bit hard to figure out the boundaries and whitespaces of the default slot:

<Component>
    <span>some code for default slot here</span>
    <div slot="a"></div>
    <span>some code for default slot here 2</span>
    <div slot="b"></div>
    some code for default slot here 3
</Component>

// default slot should contain

<span>some code for default slot here</span>
<span>some code for default slot here 2</span>
some code for default slot here 3

although it works, but it is messy. and it is hard to determine whether there's default slot in the first place, for example:

<Component>
    <div slot="a"></div>

   <!-- some white space -->
    <div slot="b"></div>
</Component>

Describe the solution you'd like
With #4556, we should complain if there's a mix of named slots and default slots, and encourage the user to use <svelte:slot slot="default"> and write:

<Component>
    <div slot="a"></div>
    <div slot="b"></div>
    <svelte:slot slot="default">
        <span>some code for default slot here</span>
       <span>some code for default slot here 2</span>
        some code for default slot here 3
    </svelte:slot>
</Component>

so, as long as there's name slot, any whitespace within the <Component> will not be considered.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

How important is this feature to you?
simpler and cleaner implementation of the slot mechanism

Additional context
Add any other context or screenshots about the feature request here.

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