Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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