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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/vdom/helpers/resolve-async-component.js
Expand Up @@ -53,7 +53,7 @@ export function resolveAsyncComponent (
}

const owner = currentRenderingInstance
if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1 && owner) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If so, I think should put owner ahead.

// already pending
factory.owners.push(owner)
}
Expand All @@ -62,7 +62,7 @@ export function resolveAsyncComponent (
return factory.loadingComp
}

if (!isDef(factory.owners)) {
if (!isDef(factory.owners) && owner) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The same as here

const owners = factory.owners = [owner]
let sync = true

Expand Down
35 changes: 35 additions & 0 deletions test/ssr/ssr-string.spec.js
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