fix(keep-alive): fix keep-alive rendering when placed in vnode branch
fix #4817
This commit is contained in:
parent
3705b3b46a
commit
0841b9b524
@ -96,8 +96,11 @@ const KeepAliveImpl: ComponentOptions = {
|
|||||||
|
|
||||||
// if the internal renderer is not registered, it indicates that this is server-side rendering,
|
// if the internal renderer is not registered, it indicates that this is server-side rendering,
|
||||||
// for KeepAlive, we just need to render its children
|
// for KeepAlive, we just need to render its children
|
||||||
if (!sharedContext.renderer) {
|
if (__SSR__ && !sharedContext.renderer) {
|
||||||
return slots.default
|
return () => {
|
||||||
|
const children = slots.default && slots.default()
|
||||||
|
return children && children.length === 1 ? children[0] : children
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cache: Cache = new Map()
|
const cache: Cache = new Map()
|
||||||
|
@ -676,7 +676,7 @@ function testRender(type: string, render: typeof renderToString) {
|
|||||||
render: () => h('p', 'hello')
|
render: () => h('p', 'hello')
|
||||||
}
|
}
|
||||||
expect(await render(h(KeepAlive, () => h(MyComp)))).toBe(
|
expect(await render(h(KeepAlive, () => h(MyComp)))).toBe(
|
||||||
`<!--[--><p>hello</p><!--]-->`
|
`<p>hello</p>`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user