Skip to content

Commit b1a434c

Browse files
committed
fix: rendering async comp after context destroyed
fix #9571
1 parent 59d8579 commit b1a434c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

+14-5
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,27 @@ export function resolveAsyncComponent (
5151
return factory.resolved
5252
}
5353

54+
const owner = currentRenderingInstance
55+
if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
56+
// already pending
57+
factory.owners.push(owner)
58+
}
59+
5460
if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
5561
return factory.loadingComp
5662
}
5763

58-
const owner = currentRenderingInstance
59-
if (isDef(factory.owners)) {
60-
// already pending
61-
factory.owners.push(owner)
62-
} else {
64+
if (!isDef(factory.owners)) {
6365
const owners = factory.owners = [owner]
6466
let sync = true
6567

68+
const removeOwner = (destroyedOwner) => {
69+
const index = owners.indexOf(destroyedOwner)
70+
if (index > -1) owners.splice(index, 1)
71+
}
72+
73+
if (owner) owner.$on('hook:destroyed', () => removeOwner(owner))
74+
6675
const forceRender = (renderCompleted: boolean) => {
6776
for (let i = 0, l = owners.length; i < l; i++) {
6877
(owners[i]: any).$forceUpdate()

0 commit comments

Comments
 (0)