fix: patching a component with pending async setup should update its props and slots
This commit is contained in:
parent
356a01780b
commit
dff4e7cd44
@ -844,19 +844,28 @@ export function createRenderer<
|
|||||||
const instance = (n2.component =
|
const instance = (n2.component =
|
||||||
n1.component) as ComponentInternalInstance
|
n1.component) as ComponentInternalInstance
|
||||||
|
|
||||||
// async still pending
|
|
||||||
if (
|
|
||||||
__FEATURE_SUSPENSE__ &&
|
|
||||||
instance.asyncDep &&
|
|
||||||
!instance.asyncResolved
|
|
||||||
) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldUpdateComponent(n1, n2, optimized)) {
|
if (shouldUpdateComponent(n1, n2, optimized)) {
|
||||||
// normal update
|
if (
|
||||||
instance.next = n2
|
__FEATURE_SUSPENSE__ &&
|
||||||
instance.update()
|
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)
|
||||||
|
}
|
||||||
|
updateComponentPropsAndSlots(instance, n2)
|
||||||
|
if (__DEV__) {
|
||||||
|
popWarningContext()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
// normal update
|
||||||
|
instance.next = n2
|
||||||
|
// instance.update is the reactive effect runner.
|
||||||
|
instance.update()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// no update needed. just copy over properties
|
// no update needed. just copy over properties
|
||||||
n2.component = n1.component
|
n2.component = n1.component
|
||||||
@ -981,12 +990,7 @@ export function createRenderer<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next !== null) {
|
if (next !== null) {
|
||||||
// update from parent
|
updateComponentPropsAndSlots(instance, next)
|
||||||
next.component = instance
|
|
||||||
instance.vnode = next
|
|
||||||
instance.next = null
|
|
||||||
resolveProps(instance, next.props, (initialVNode.type as any).props)
|
|
||||||
resolveSlots(instance, next.children)
|
|
||||||
}
|
}
|
||||||
const prevTree = instance.subTree
|
const prevTree = instance.subTree
|
||||||
const nextTree = (instance.subTree = renderComponentRoot(instance))
|
const nextTree = (instance.subTree = renderComponentRoot(instance))
|
||||||
@ -1030,6 +1034,17 @@ export function createRenderer<
|
|||||||
}, __DEV__ ? createDevEffectOptions(instance) : prodEffectOptions)
|
}, __DEV__ ? createDevEffectOptions(instance) : prodEffectOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateComponentPropsAndSlots(
|
||||||
|
instance: ComponentInternalInstance,
|
||||||
|
nextVNode: HostVNode
|
||||||
|
) {
|
||||||
|
nextVNode.component = instance
|
||||||
|
instance.vnode = nextVNode
|
||||||
|
instance.next = null
|
||||||
|
resolveProps(instance, nextVNode.props, (nextVNode.type as any).props)
|
||||||
|
resolveSlots(instance, nextVNode.children)
|
||||||
|
}
|
||||||
|
|
||||||
function updateHOCHostEl(
|
function updateHOCHostEl(
|
||||||
{ vnode, parent }: ComponentInternalInstance,
|
{ vnode, parent }: ComponentInternalInstance,
|
||||||
el: HostNode
|
el: HostNode
|
||||||
@ -1624,11 +1639,7 @@ export function createRenderer<
|
|||||||
function getSequence(arr: number[]): number[] {
|
function getSequence(arr: number[]): number[] {
|
||||||
const p = arr.slice()
|
const p = arr.slice()
|
||||||
const result = [0]
|
const result = [0]
|
||||||
let i
|
let i, j, u, v, c
|
||||||
let j
|
|
||||||
let u
|
|
||||||
let v
|
|
||||||
let c
|
|
||||||
const len = arr.length
|
const len = arr.length
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const arrI = arr[i]
|
const arrI = arr[i]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user