From a651fc44f6937d40a2c28b3d37737ff1e343a087 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 2 Nov 2019 21:26:25 -0400 Subject: [PATCH] refactor: adjust shapeFlag naming --- packages/runtime-core/src/components/KeepAlive.ts | 4 ++-- packages/runtime-core/src/renderer.ts | 9 ++++----- packages/runtime-core/src/shapeFlags.ts | 6 ++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index 6b4618fdb..d618c8550 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -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 diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 2d6d5d5a5..8f67ce6b4 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -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) } diff --git a/packages/runtime-core/src/shapeFlags.ts b/packages/runtime-core/src/shapeFlags.ts index 56c5d164a..af91ae7de 100644 --- a/packages/runtime-core/src/shapeFlags.ts +++ b/packages/runtime-core/src/shapeFlags.ts @@ -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 }