mirror of https://github.com/vuejs/core.git
fix(hydration): prevent lazy hydration for updated components
This commit is contained in:
parent
5f8314cb7f
commit
028aaae7a0
|
@ -123,28 +123,28 @@ export function defineAsyncComponent<
|
||||||
|
|
||||||
__asyncHydrate(el, instance, hydrate) {
|
__asyncHydrate(el, instance, hydrate) {
|
||||||
let patched = false
|
let patched = false
|
||||||
const doHydrate = hydrateStrategy
|
;(instance.bu || (instance.bu = [])).push(() => (patched = true))
|
||||||
? () => {
|
|
||||||
const performHydrate = () => {
|
const performHydrate = () => {
|
||||||
// skip hydration if the component has been patched
|
// skip hydration if the component has been patched
|
||||||
if (__DEV__ && patched) {
|
if (__DEV__ && patched) {
|
||||||
warn(
|
warn(
|
||||||
`Skipping lazy hydration for component '${getComponentName(resolvedComp!)}': ` +
|
`Skipping lazy hydration for component '${getComponentName(resolvedComp!) || resolvedComp!.__file}': ` +
|
||||||
`it was updated before lazy hydration performed.`,
|
`it was updated before lazy hydration performed.`,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
hydrate()
|
hydrate()
|
||||||
}
|
}
|
||||||
|
const doHydrate = hydrateStrategy
|
||||||
|
? () => {
|
||||||
const teardown = hydrateStrategy(performHydrate, cb =>
|
const teardown = hydrateStrategy(performHydrate, cb =>
|
||||||
forEachElement(el, cb),
|
forEachElement(el, cb),
|
||||||
)
|
)
|
||||||
if (teardown) {
|
if (teardown) {
|
||||||
;(instance.bum || (instance.bum = [])).push(teardown)
|
;(instance.bum || (instance.bum = [])).push(teardown)
|
||||||
}
|
}
|
||||||
;(instance.u || (instance.u = [])).push(() => (patched = true))
|
|
||||||
}
|
}
|
||||||
: hydrate
|
: performHydrate
|
||||||
if (resolvedComp) {
|
if (resolvedComp) {
|
||||||
doHydrate()
|
doHydrate()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue