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 #9571, rendering async components after initial context was destroyed #9572

Merged
merged 3 commits into from Feb 28, 2019
Merged
Changes from all commits
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
17 changes: 11 additions & 6 deletions src/core/vdom/helpers/resolve-async-component.js
Expand Up @@ -8,7 +8,8 @@ import {
isTrue,
isObject,
hasSymbol,
isPromise
isPromise,
remove
} from 'core/util/index'

import { createEmptyVNode } from 'core/vdom/vnode'
Expand Down Expand Up @@ -51,17 +52,21 @@ export function resolveAsyncComponent (
return factory.resolved
}

const owner = currentRenderingInstance
if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
// already pending
factory.owners.push(owner)
}

if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
return factory.loadingComp
}

const owner = currentRenderingInstance
if (isDef(factory.owners)) {
// already pending
factory.owners.push(owner)
} else {
if (!isDef(factory.owners)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not too happy with double checking for isDef(factory.owners) here and above but cleaner than moving this block above the block which returns the loadingComp I guess?!

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

if (owner) owner.$on('hook:destroyed', () => remove(owners, owner))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This stuff isn't mandatory. It doesn't break anything if destroyed owners are force updated. But it might be cleaner to remove them.

const forceRender = (renderCompleted: boolean) => {
for (let i = 0, l = owners.length; i < l; i++) {
Expand Down