refactor(runtime-core): move updateCompnent into separate function
This commit is contained in:
parent
2fb0adda50
commit
cda50ea788
@ -968,38 +968,7 @@ function baseCreateRenderer(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
const instance = (n2.component = n1.component)!
|
||||
|
||||
if (shouldUpdateComponent(n1, n2, parentComponent, optimized)) {
|
||||
if (
|
||||
__FEATURE_SUSPENSE__ &&
|
||||
instance.asyncDep &&
|
||||
!instance.asyncResolved
|
||||
) {
|
||||
// async & still pending - just update props and slots
|
||||
// since the component's reactive effect for render isn't set-up yet
|
||||
if (__DEV__) {
|
||||
pushWarningContext(n2)
|
||||
}
|
||||
updateComponentPreRender(instance, n2, optimized)
|
||||
if (__DEV__) {
|
||||
popWarningContext()
|
||||
}
|
||||
return
|
||||
} else {
|
||||
// normal update
|
||||
instance.next = n2
|
||||
// in case the child component is also queued, remove it to avoid
|
||||
// double updating the same child component in the same flush.
|
||||
invalidateJob(instance.update)
|
||||
// instance.update is the reactive effect runner.
|
||||
instance.update()
|
||||
}
|
||||
} else {
|
||||
// no update needed. just copy over properties
|
||||
n2.component = n1.component
|
||||
n2.el = n1.el
|
||||
}
|
||||
updateComponent(n1, n2, parentComponent, optimized)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1077,6 +1046,45 @@ function baseCreateRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
const updateComponent = (
|
||||
n1: VNode,
|
||||
n2: VNode,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
optimized: boolean
|
||||
) => {
|
||||
const instance = (n2.component = n1.component)!
|
||||
if (shouldUpdateComponent(n1, n2, parentComponent, optimized)) {
|
||||
if (
|
||||
__FEATURE_SUSPENSE__ &&
|
||||
instance.asyncDep &&
|
||||
!instance.asyncResolved
|
||||
) {
|
||||
// async & still pending - just update props and slots
|
||||
// since the component's reactive effect for render isn't set-up yet
|
||||
if (__DEV__) {
|
||||
pushWarningContext(n2)
|
||||
}
|
||||
updateComponentPreRender(instance, n2, optimized)
|
||||
if (__DEV__) {
|
||||
popWarningContext()
|
||||
}
|
||||
return
|
||||
} else {
|
||||
// normal update
|
||||
instance.next = n2
|
||||
// in case the child component is also queued, remove it to avoid
|
||||
// double updating the same child component in the same flush.
|
||||
invalidateJob(instance.update)
|
||||
// instance.update is the reactive effect runner.
|
||||
instance.update()
|
||||
}
|
||||
} else {
|
||||
// no update needed. just copy over properties
|
||||
n2.component = n1.component
|
||||
n2.el = n1.el
|
||||
}
|
||||
}
|
||||
|
||||
const setupRenderEffect: SetupRenderEffectFn = (
|
||||
instance,
|
||||
initialVNode,
|
||||
|
Loading…
Reference in New Issue
Block a user