Browse Source

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

fix #9643
dev
krystal 6 years ago
committed by Evan You
parent
commit
8082d2f910
  1. 4
      src/core/vdom/helpers/resolve-async-component.js
  2. 35
      test/ssr/ssr-string.spec.js

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

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

35
test/ssr/ssr-string.spec.js

@ -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…
Cancel
Save