fix(ssr): fix nested async functional componet rendering (#9673)

fix #9643
This commit is contained in:
krystal 2019-03-13 17:20:28 +08:00 committed by Evan You
parent 7591b9dc6d
commit 8082d2f910
2 changed files with 37 additions and 2 deletions

View File

@ -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

View File

@ -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({