Skip to content

Use slot prop in custom svelte component. #5098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheComputerM opened this issue Jul 4, 2020 · 3 comments
Closed

Use slot prop in custom svelte component. #5098

TheComputerM opened this issue Jul 4, 2020 · 3 comments
Assignees
Labels
awaiting submitter needs a reproduction, or clarification

Comments

@TheComputerM
Copy link

We cannot use slot prop in custom components, this messes up components that work with flexbox and other tools that depend on component structure.

ChildComponent.svelte

<p> I need to be directly a child of ParentComponent.svelte</p>

ParentComponent.svelte

<div>
    <slot name="child" />
    <div class="content"><slot/></div>
</div>

App.svelte

import ChildComponent from "ChildComponent.svelte";
import ParentComponent from "ParentComponent.svelte";
<ParentComponent>
    <div slot="child">
        <ChildComponent />
    </div>
    This is the content
</ParentComponent>

This is the output

<div>
    <div>
        <p> I need to be directly a child of ParentComponent.svelte</p>
    </div>
    <div class="content">
        This is the content
    </div>
</div>

As you can see the <p> tag is not a direct child. I propose that slot be a reserved keyword and can used by any component.

@antony antony added the awaiting submitter needs a reproduction, or clarification label Jul 4, 2020
@antony
Copy link
Member

antony commented Jul 4, 2020

I have a feeling that this is covered by the one of the slots proposals, but I could be wrong. @tanhauhau can you clarify?

@pngwn
Copy link
Member

pngwn commented Jul 4, 2020

I'm pretty sure #4556 would take care of this.

@Conduitry
Copy link
Member

Yeah duplicate of #1037 and #2080 and probably some other issues. This would be handled by something like #4556.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification
Projects
None yet
Development

No branches or pull requests

5 participants