Slot forwarding and render functions #672
diachedelic
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It seems that there is no reliable way for a component written using render functions to forward a slot. As best I can tell, forwarding can only be made to work by rewriting the component with an SFC-style template, or (in some special cases) by exploiting Vue internals. The problem is described, with reproductions, in discussion vuejs/core#10847.
My proposal is that Vue could infer forwarded slots by comparing function references. For example, consider the following trivial component. All it does is wrap its default slot in a
<div>
element.The
render
function returns a vnode containing the slot function, unaltered:Notice that the slot function in this vnode is identical to the slot function passed in to
setup
. It seems possible, then, that Vue could detect the equality of the two functions during rendering (i.e.vnode.children.default === slots.default
) and thus provide the same optimisation available to template components.I am aware that I may be asking the impossible, and if so I apologise in advance. I am willing to do more research if somebody wants to point me in the right direction.
Beta Was this translation helpful? Give feedback.
All reactions