fix(ssr): render teleport inside async component (#5187)
This commit is contained in:
parent
31c0bb355a
commit
4d7803ed28
@ -117,4 +117,21 @@ describe('ssrRenderTeleport', () => {
|
|||||||
'<span>hello</span><!---->world<!---->'
|
'<span>hello</span><!---->world<!---->'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('teleport inside async component', async () => {
|
||||||
|
const ctx: SSRContext = {}
|
||||||
|
const asyncComponent = {
|
||||||
|
template: '<teleport to="#target"><div>content</div></teleport>',
|
||||||
|
async setup() {}
|
||||||
|
}
|
||||||
|
const html = await renderToString(
|
||||||
|
h({
|
||||||
|
template: '<async-component />',
|
||||||
|
components: { asyncComponent }
|
||||||
|
}),
|
||||||
|
ctx
|
||||||
|
)
|
||||||
|
expect(html).toBe('<!--teleport start--><!--teleport end-->')
|
||||||
|
expect(ctx.teleports!['#target']).toBe(`<div>content</div><!---->`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -63,9 +63,11 @@ export async function renderToString(
|
|||||||
input.provide(ssrContextKey, context)
|
input.provide(ssrContextKey, context)
|
||||||
const buffer = await renderComponentVNode(vnode)
|
const buffer = await renderComponentVNode(vnode)
|
||||||
|
|
||||||
|
const result = await unrollBuffer(buffer as SSRBuffer)
|
||||||
|
|
||||||
await resolveTeleports(context)
|
await resolveTeleports(context)
|
||||||
|
|
||||||
return unrollBuffer(buffer as SSRBuffer)
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveTeleports(context: SSRContext) {
|
async function resolveTeleports(context: SSRContext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user