From 847d7f782bb6074c6b31378e07d94cb41ad30bd2 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 17 May 2022 17:45:53 +0800 Subject: [PATCH] fix(ssr): inherit scope id on functional component during ssr fix #5817 --- packages/server-renderer/src/render.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/server-renderer/src/render.ts b/packages/server-renderer/src/render.ts index 4090ef9f..ae71a9e6 100644 --- a/packages/server-renderer/src/render.ts +++ b/packages/server-renderer/src/render.ts @@ -4,6 +4,7 @@ import { ComponentInternalInstance, DirectiveBinding, Fragment, + FunctionalComponent, mergeProps, ssrUtils, Static, @@ -112,12 +113,17 @@ function renderComponentSubTree( const comp = instance.type as Component const { getBuffer, push } = createBuffer() if (isFunction(comp)) { - renderVNode( - push, - (instance.subTree = renderComponentRoot(instance)), - instance, - slotScopeId - ) + let root = renderComponentRoot(instance) + // #5817 scope ID attrs not falling through if functional component doesn't + // have props + if (!(comp as FunctionalComponent).props) { + for (const key in instance.attrs) { + if (key.startsWith(`data-v-`)) { + ;(root.props || (root.props = {}))[key] = `` + } + } + } + renderVNode(push, (instance.subTree = root), instance, slotScopeId) } else { if ( (!instance.render || instance.render === NOOP) &&