refactor: adjust shapeFlag naming
This commit is contained in:
parent
90b9884eb4
commit
a651fc44f6
@ -180,7 +180,7 @@ export const KeepAlive = {
|
|||||||
vnode.anchor = cached.anchor
|
vnode.anchor = cached.anchor
|
||||||
vnode.component = cached.component
|
vnode.component = cached.component
|
||||||
// avoid vnode being mounted as fresh
|
// avoid vnode being mounted as fresh
|
||||||
vnode.shapeFlag |= ShapeFlags.STATEFUL_COMPONENT_KEPT_ALIVE
|
vnode.shapeFlag |= ShapeFlags.COMPONENT_KEPT_ALIVE
|
||||||
// make this key the freshest
|
// make this key the freshest
|
||||||
keys.delete(key)
|
keys.delete(key)
|
||||||
keys.add(key)
|
keys.add(key)
|
||||||
@ -192,7 +192,7 @@ export const KeepAlive = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// avoid vnode being unmounted
|
// avoid vnode being unmounted
|
||||||
vnode.shapeFlag |= ShapeFlags.STATEFUL_COMPONENT_SHOULD_KEEP_ALIVE
|
vnode.shapeFlag |= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
||||||
|
|
||||||
current = vnode
|
current = vnode
|
||||||
return vnode
|
return vnode
|
||||||
|
@ -756,7 +756,7 @@ export function createRenderer<
|
|||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
if (n1 == null) {
|
if (n1 == null) {
|
||||||
if (n2.shapeFlag & ShapeFlags.STATEFUL_COMPONENT_KEPT_ALIVE) {
|
if (n2.shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE) {
|
||||||
;(parentComponent!.sink as KeepAliveSink).activate(
|
;(parentComponent!.sink as KeepAliveSink).activate(
|
||||||
n2,
|
n2,
|
||||||
container,
|
container,
|
||||||
@ -903,8 +903,7 @@ export function createRenderer<
|
|||||||
// activated hook for keep-alive roots.
|
// activated hook for keep-alive roots.
|
||||||
if (
|
if (
|
||||||
instance.a !== null &&
|
instance.a !== null &&
|
||||||
instance.vnode.shapeFlag &
|
instance.vnode.shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
||||||
ShapeFlags.STATEFUL_COMPONENT_SHOULD_KEEP_ALIVE
|
|
||||||
) {
|
) {
|
||||||
queuePostRenderEffect(instance.a, parentSuspense)
|
queuePostRenderEffect(instance.a, parentSuspense)
|
||||||
}
|
}
|
||||||
@ -1409,7 +1408,7 @@ export function createRenderer<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shapeFlag & ShapeFlags.COMPONENT) {
|
if (shapeFlag & ShapeFlags.COMPONENT) {
|
||||||
if (shapeFlag & ShapeFlags.STATEFUL_COMPONENT_SHOULD_KEEP_ALIVE) {
|
if (shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) {
|
||||||
;(parentComponent!.sink as KeepAliveSink).deactivate(vnode)
|
;(parentComponent!.sink as KeepAliveSink).deactivate(vnode)
|
||||||
} else {
|
} else {
|
||||||
unmountComponent(vnode.component!, parentSuspense, doRemove)
|
unmountComponent(vnode.component!, parentSuspense, doRemove)
|
||||||
@ -1484,7 +1483,7 @@ export function createRenderer<
|
|||||||
if (
|
if (
|
||||||
da !== null &&
|
da !== null &&
|
||||||
!isDeactivated &&
|
!isDeactivated &&
|
||||||
instance.vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT_SHOULD_KEEP_ALIVE
|
instance.vnode.shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
||||||
) {
|
) {
|
||||||
queuePostRenderEffect(da, parentSuspense)
|
queuePostRenderEffect(da, parentSuspense)
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ export const enum ShapeFlags {
|
|||||||
ARRAY_CHILDREN = 1 << 4,
|
ARRAY_CHILDREN = 1 << 4,
|
||||||
SLOTS_CHILDREN = 1 << 5,
|
SLOTS_CHILDREN = 1 << 5,
|
||||||
SUSPENSE = 1 << 6,
|
SUSPENSE = 1 << 6,
|
||||||
STATEFUL_COMPONENT_SHOULD_KEEP_ALIVE = 1 << 7,
|
COMPONENT_SHOULD_KEEP_ALIVE = 1 << 7,
|
||||||
STATEFUL_COMPONENT_KEPT_ALIVE = 1 << 8,
|
COMPONENT_KEPT_ALIVE = 1 << 8,
|
||||||
COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
|
COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,5 +20,7 @@ export const PublicShapeFlags = {
|
|||||||
ARRAY_CHILDREN: ShapeFlags.ARRAY_CHILDREN,
|
ARRAY_CHILDREN: ShapeFlags.ARRAY_CHILDREN,
|
||||||
SLOTS_CHILDREN: ShapeFlags.SLOTS_CHILDREN,
|
SLOTS_CHILDREN: ShapeFlags.SLOTS_CHILDREN,
|
||||||
SUSPENSE: ShapeFlags.SUSPENSE,
|
SUSPENSE: ShapeFlags.SUSPENSE,
|
||||||
|
COMPONENT_SHOULD_KEEP_ALIVE: ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE,
|
||||||
|
COMPONENT_KEPT_ALIVE: ShapeFlags.COMPONENT_KEPT_ALIVE,
|
||||||
COMPONENT: ShapeFlags.COMPONENT
|
COMPONENT: ShapeFlags.COMPONENT
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user