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