mirror of https://github.com/vuejs/core.git
refactor: more concise bitwise operations for flag removal (#7092)
This commit is contained in:
parent
845efbbb5d
commit
4798a9f704
|
@ -424,14 +424,9 @@ function injectToKeepAliveRoot(
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetShapeFlag(vnode: VNode) {
|
function resetShapeFlag(vnode: VNode) {
|
||||||
let shapeFlag = vnode.shapeFlag
|
// bitwise operations to remove keep alive flags
|
||||||
if (shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) {
|
vnode.shapeFlag &= ~ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
||||||
shapeFlag -= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
vnode.shapeFlag &= ~ShapeFlags.COMPONENT_KEPT_ALIVE
|
||||||
}
|
|
||||||
if (shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE) {
|
|
||||||
shapeFlag -= ShapeFlags.COMPONENT_KEPT_ALIVE
|
|
||||||
}
|
|
||||||
vnode.shapeFlag = shapeFlag
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInnerChild(vnode: VNode) {
|
function getInnerChild(vnode: VNode) {
|
||||||
|
|
|
@ -358,13 +358,9 @@ export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
|
||||||
hmrDirtyComponents.has(n2.type as ConcreteComponent)
|
hmrDirtyComponents.has(n2.type as ConcreteComponent)
|
||||||
) {
|
) {
|
||||||
// #7042, ensure the vnode being unmounted during HMR
|
// #7042, ensure the vnode being unmounted during HMR
|
||||||
if (n1.shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) {
|
// bitwise operations to remove keep alive flags
|
||||||
n1.shapeFlag -= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
n1.shapeFlag &= ~ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
||||||
}
|
n2.shapeFlag &= ~ShapeFlags.COMPONENT_KEPT_ALIVE
|
||||||
// #7042, ensure the vnode being mounted as fresh during HMR
|
|
||||||
if (n2.shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE) {
|
|
||||||
n2.shapeFlag -= ShapeFlags.COMPONENT_KEPT_ALIVE
|
|
||||||
}
|
|
||||||
// HMR only: if the component has been hot-updated, force a reload.
|
// HMR only: if the component has been hot-updated, force a reload.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue