Skip to content

Commit

Permalink
fix: rendering async comp after context destroyed
Browse files Browse the repository at this point in the history
fix #9571
  • Loading branch information
maoberlehner committed Feb 26, 2019
1 parent 59d8579 commit b1a434c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/core/vdom/helpers/resolve-async-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,27 @@ 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)) {
const owners = factory.owners = [owner]
let sync = true

const removeOwner = (destroyedOwner) => {
const index = owners.indexOf(destroyedOwner)
if (index > -1) owners.splice(index, 1)
}

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

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

0 comments on commit b1a434c

Please sign in to comment.