Skip to content

feat(vapor): forwarded slots #13408

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

Open
wants to merge 856 commits into
base: minor
Choose a base branch
from
Open

feat(vapor): forwarded slots #13408

wants to merge 856 commits into from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented May 29, 2025

Playground with this PR

foo is a forwarded slot, it is executed, the currentInstance in createSlot is the instance of Comp, but it should be the instance of Comp1.

 const n2 = _createComponent(Comp, null, { "foo": () => { const n0 = _createSlot("foo", null) return n0 } }, true)

Therefore, we need to preserve the current component's instance for forwarded slots and use it in createSlot, similar to how withCtx works in VDOM slots. With this PR, the compiled code changes to:

 const _createForwardedSlot = _forwardedSlotCreator() const n2 = _createComponent(Comp, null, { "foo": () => { const n0 = _createForwardedSlot("foo", null) return n0 } }, true)

Inside the forwardedSlotCreator, the currentInstance is retained and a function is returned, which calls createSlot and passes the retained instance.

@edison1105 edison1105 marked this pull request as ready for review June 12, 2025 08:00
edison1105 and others added 25 commits June 13, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: vapor related to vapor mode
6 participants