mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-29 18:47:39 +08:00
fix(ssr): fix nested async functional componet rendering (#9673)
fix #9643
This commit is contained in:
parent
7591b9dc6d
commit
8082d2f910
@ -53,7 +53,7 @@ export function resolveAsyncComponent (
|
||||
}
|
||||
|
||||
const owner = currentRenderingInstance
|
||||
if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
|
||||
if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
|
||||
// already pending
|
||||
factory.owners.push(owner)
|
||||
}
|
||||
@ -62,7 +62,7 @@ export function resolveAsyncComponent (
|
||||
return factory.loadingComp
|
||||
}
|
||||
|
||||
if (!isDef(factory.owners)) {
|
||||
if (owner && !isDef(factory.owners)) {
|
||||
const owners = factory.owners = [owner]
|
||||
let sync = true
|
||||
|
||||
|
@ -640,6 +640,41 @@ describe('SSR: renderToString', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('renders nested async functional component', done => {
|
||||
renderVmWithOptions({
|
||||
template: `
|
||||
<div>
|
||||
<outer-async></outer-async>
|
||||
</div>
|
||||
`,
|
||||
components: {
|
||||
outerAsync (resolve) {
|
||||
setTimeout(() => resolve({
|
||||
functional: true,
|
||||
render (h) {
|
||||
return h('innerAsync')
|
||||
}
|
||||
}), 1)
|
||||
},
|
||||
innerAsync (resolve) {
|
||||
setTimeout(() => resolve({
|
||||
functional: true,
|
||||
render (h) {
|
||||
return h('span', { class: ['a'] }, 'inner')
|
||||
},
|
||||
}), 1)
|
||||
}
|
||||
}
|
||||
}, result => {
|
||||
expect(result).toContain(
|
||||
'<div data-server-rendered="true">' +
|
||||
'<span class="a">inner</span>' +
|
||||
'</div>'
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should catch async component error', done => {
|
||||
Vue.config.silent = true
|
||||
renderToString(new Vue({
|
||||
|
Loading…
Reference in New Issue
Block a user