Skip to content

Commit

Permalink
fix(ssr): fix nested async functional componet rendering (#9673)
Browse files Browse the repository at this point in the history
fix #9643
  • Loading branch information
dejour authored and yyx990803 committed Mar 13, 2019
1 parent 7591b9d commit 8082d2f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/vdom/helpers/resolve-async-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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

Expand Down
35 changes: 35 additions & 0 deletions test/ssr/ssr-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

1 comment on commit 8082d2f

@xiaoxiaoxiao123qwe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

Please sign in to comment.