From: 花果山大圣 <316783812@qq.com> Date: Fri, 11 Nov 2022 01:15:37 +0000 (+0800) Subject: refactor: more concise bitwise operations for flag removal (#7092) X-Git-Tag: v3.2.45~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4798a9f704061974614d1bf171772f452f663df4;p=thirdparty%2Fvuejs%2Fcore.git refactor: more concise bitwise operations for flag removal (#7092) --- diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index 3fec48140f..66d0f82a10 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -424,14 +424,9 @@ function injectToKeepAliveRoot( } function resetShapeFlag(vnode: VNode) { - let shapeFlag = vnode.shapeFlag - if (shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) { - shapeFlag -= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE - } - if (shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE) { - shapeFlag -= ShapeFlags.COMPONENT_KEPT_ALIVE - } - vnode.shapeFlag = shapeFlag + // bitwise operations to remove keep alive flags + vnode.shapeFlag &= ~ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE + vnode.shapeFlag &= ~ShapeFlags.COMPONENT_KEPT_ALIVE } function getInnerChild(vnode: VNode) { diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index 41f848e44d..7d873f5a12 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -358,13 +358,9 @@ export function isSameVNodeType(n1: VNode, n2: VNode): boolean { hmrDirtyComponents.has(n2.type as ConcreteComponent) ) { // #7042, ensure the vnode being unmounted during HMR - if (n1.shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) { - n1.shapeFlag -= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE - } - // #7042, ensure the vnode being mounted as fresh during HMR - if (n2.shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE) { - n2.shapeFlag -= ShapeFlags.COMPONENT_KEPT_ALIVE - } + // bitwise operations to remove keep alive flags + n1.shapeFlag &= ~ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE + n2.shapeFlag &= ~ShapeFlags.COMPONENT_KEPT_ALIVE // HMR only: if the component has been hot-updated, force a reload. return false }