Skip to content

Commit 0c57049

Browse files
author
Matt Lavallee
committed
fix(async component): accounting for async components with loading property
1 parent 0af4bf8 commit 0c57049

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Diff for: src/core/vdom/helpers/resolve-async-component.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,18 @@ export function resolveAsyncComponent (
6161
const contexts = factory.contexts = [context]
6262
let sync = true
6363

64-
const forceRender = () => {
64+
const forceRender = (renderCompleted: boolean) => {
6565
for (let i = 0, l = contexts.length; i < l; i++) {
6666
contexts[i].$forceUpdate()
6767

68-
const currContext = contexts[i]
69-
const contextIdx = contexts.indexOf(currContext)
70-
if (contextIdx >= 0) {
71-
currContext.$nextTick(() => {
72-
contexts.splice(contextIdx, 1)
73-
})
68+
if (!renderCompleted) {
69+
continue
7470
}
71+
72+
const contextIdx = i
73+
contexts[i].$nextTick(() => {
74+
contexts.splice(contextIdx, 1)
75+
})
7576
}
7677
}
7778

@@ -81,7 +82,7 @@ export function resolveAsyncComponent (
8182
// invoke callbacks only if this is not a synchronous resolve
8283
// (async resolves are shimmed as synchronous during SSR)
8384
if (!sync) {
84-
forceRender()
85+
forceRender(true)
8586
}
8687
})
8788

@@ -92,7 +93,7 @@ export function resolveAsyncComponent (
9293
)
9394
if (isDef(factory.errorComp)) {
9495
factory.error = true
95-
forceRender()
96+
forceRender(true)
9697
}
9798
})
9899

@@ -119,7 +120,7 @@ export function resolveAsyncComponent (
119120
setTimeout(() => {
120121
if (isUndef(factory.resolved) && isUndef(factory.error)) {
121122
factory.loading = true
122-
forceRender()
123+
forceRender(false)
123124
}
124125
}, res.delay || 200)
125126
}

0 commit comments

Comments
 (0)