Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(ssr): inherit scope id on functional component during ssr
fix #5817
  • Loading branch information
yyx990803 committed May 17, 2022
1 parent 415091b commit 847d7f7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/server-renderer/src/render.ts
Expand Up @@ -4,6 +4,7 @@ import {
ComponentInternalInstance,
DirectiveBinding,
Fragment,
FunctionalComponent,
mergeProps,
ssrUtils,
Static,
Expand Down Expand Up @@ -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) &&
Expand Down

0 comments on commit 847d7f7

Please sign in to comment.