-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
add slots option to component constructor options object #4296
Conversation
9678ca5
to
7f8c5f1
Compare
I'm assuming this doesn't support any sort of interactivity between the component and the slots you pass to it? I think the main thing I'm worried about here is forcing everyone who uses slots to ship this extra code, whether they want the functionality or not. |
So I guess maybe we can add a compile option to turn this on? |
Maybe. I'd prefer in general not to add compiler options though - and it feels like most of this feature already exists, just as part of the private |
If the extra bytes are only added in the case of components that accept slot content, that seems reasonable to me. I imagine that the general case by far for a component with |
Requiring a compilation option or special outside code to pass in slot content to the constructor function of a component that has a |
7f8c5f1
to
969ad23
Compare
will it be too much if to ask the user to call |
How would a user create Svelte components to pass as slots? Since creating such a component requires a const wrapper = document.createElement("div");
const slot = new SlotComponent({target: wrapper});
const actual = new ActualComponent({target: ..., slots: {default: slot}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly less runtime 😉
I think this is missing the ability to mount a Component inside a slot? new Parent({
target: document.body,
props: { ... },
slots: {
// Parent has all info to `new Child`
default: Child
}
}); |
Co-authored-by: Luke Edwards <[email protected]>
Co-authored-by: Luke Edwards <[email protected]>
Co-authored-by: Luke Edwards <[email protected]>
Is this how we are going to pass a component into a slot? What would be the props of the component? |
This is what I ended up with, and is working for me already: new Parent({
target: document.body,
props: {
$$scope: {},
$$slots: create({
default: [ Child ],
// Or
default: [ new Child({ $$inline: true, props: {...} }) ]
})
}
});
If this is the approach we want to take, we can work on making it nicer / have pieces hidden. For example, a top-level |
I should also note that my |
FYI I continue this PR at #5687 |
@tanhauhau @truongsinh Isn't it weird to have two PRs with the same title, both open? |
Will this be merged, it is highly needed for testing 👀 |
Looking forward to this, which is very necessary, especially for developing components. |
Looks like svelte team work on what only matters for themselves. You'd better listen to what community want right? This is second PR that is awaiting merge related to slot. Slot is turning into a nightmare for me. You don't even bother making clear your plan about these PRs. These PRs are 2-3 years old. This is not something to postpone to later time. I wonder how you do component testing without being able to pass slot to theme? Please make clear you roadmap about slots. PLEASE! |
Is there any news on this? The slot option would be highly appreciated for component testing. |
Bumping due to how amazingly useful this would be |
Closing Svelte 4 PRs as stale — thank you |
rebased #2684
fixes #2588