core
core copied to clipboard
feat(vapor): forwarded slots
- open Playground with vapor branch
Maximum call stack size exceededoccurred
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.