fix(ssr): inherit scope id on functional component during ssr

fix #5817
This commit is contained in:
Evan You 2022-05-17 17:45:53 +08:00
parent 415091b0ee
commit 847d7f782b

View File

@ -4,6 +4,7 @@ import {
ComponentInternalInstance, ComponentInternalInstance,
DirectiveBinding, DirectiveBinding,
Fragment, Fragment,
FunctionalComponent,
mergeProps, mergeProps,
ssrUtils, ssrUtils,
Static, Static,
@ -112,12 +113,17 @@ function renderComponentSubTree(
const comp = instance.type as Component const comp = instance.type as Component
const { getBuffer, push } = createBuffer() const { getBuffer, push } = createBuffer()
if (isFunction(comp)) { if (isFunction(comp)) {
renderVNode( let root = renderComponentRoot(instance)
push, // #5817 scope ID attrs not falling through if functional component doesn't
(instance.subTree = renderComponentRoot(instance)), // have props
instance, if (!(comp as FunctionalComponent).props) {
slotScopeId for (const key in instance.attrs) {
) if (key.startsWith(`data-v-`)) {
;(root.props || (root.props = {}))[key] = ``
}
}
}
renderVNode(push, (instance.subTree = root), instance, slotScopeId)
} else { } else {
if ( if (
(!instance.render || instance.render === NOOP) && (!instance.render || instance.render === NOOP) &&