Skip to content

Commit 8082d2f

Browse files
dejouryyx990803
authored andcommitted
fix(ssr): fix nested async functional componet rendering (#9673)
fix #9643
1 parent 7591b9d commit 8082d2f

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/core/vdom/helpers/resolve-async-component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function resolveAsyncComponent (
5353
}
5454

5555
const owner = currentRenderingInstance
56-
if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
56+
if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
5757
// already pending
5858
factory.owners.push(owner)
5959
}
@@ -62,7 +62,7 @@ export function resolveAsyncComponent (
6262
return factory.loadingComp
6363
}
6464

65-
if (!isDef(factory.owners)) {
65+
if (owner && !isDef(factory.owners)) {
6666
const owners = factory.owners = [owner]
6767
let sync = true
6868

test/ssr/ssr-string.spec.js

+35
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,41 @@ describe('SSR: renderToString', () => {
640640
})
641641
})
642642

643+
it('renders nested async functional component', done => {
644+
renderVmWithOptions({
645+
template: `
646+
<div>
647+
<outer-async></outer-async>
648+
</div>
649+
`,
650+
components: {
651+
outerAsync (resolve) {
652+
setTimeout(() => resolve({
653+
functional: true,
654+
render (h) {
655+
return h('innerAsync')
656+
}
657+
}), 1)
658+
},
659+
innerAsync (resolve) {
660+
setTimeout(() => resolve({
661+
functional: true,
662+
render (h) {
663+
return h('span', { class: ['a'] }, 'inner')
664+
},
665+
}), 1)
666+
}
667+
}
668+
}, result => {
669+
expect(result).toContain(
670+
'<div data-server-rendered="true">' +
671+
'<span class="a">inner</span>' +
672+
'</div>'
673+
)
674+
done()
675+
})
676+
})
677+
643678
it('should catch async component error', done => {
644679
Vue.config.silent = true
645680
renderToString(new Vue({

0 commit comments

Comments
 (0)