Skip to content

Commit 847d7f7

Browse files
committed
fix(ssr): inherit scope id on functional component during ssr
fix #5817
1 parent 415091b commit 847d7f7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/server-renderer/src/render.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ComponentInternalInstance,
55
DirectiveBinding,
66
Fragment,
7+
FunctionalComponent,
78
mergeProps,
89
ssrUtils,
910
Static,
@@ -112,12 +113,17 @@ function renderComponentSubTree(
112113
const comp = instance.type as Component
113114
const { getBuffer, push } = createBuffer()
114115
if (isFunction(comp)) {
115-
renderVNode(
116-
push,
117-
(instance.subTree = renderComponentRoot(instance)),
118-
instance,
119-
slotScopeId
120-
)
116+
let root = renderComponentRoot(instance)
117+
// #5817 scope ID attrs not falling through if functional component doesn't
118+
// have props
119+
if (!(comp as FunctionalComponent).props) {
120+
for (const key in instance.attrs) {
121+
if (key.startsWith(`data-v-`)) {
122+
;(root.props || (root.props = {}))[key] = ``
123+
}
124+
}
125+
}
126+
renderVNode(push, (instance.subTree = root), instance, slotScopeId)
121127
} else {
122128
if (
123129
(!instance.render || instance.render === NOOP) &&

0 commit comments

Comments
 (0)