]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: merge bitwise flag checks (#4324)
authorHazlank <401840614@qq.com>
Mon, 16 Aug 2021 19:13:04 +0000 (14:13 -0500)
committerGitHub <noreply@github.com>
Mon, 16 Aug 2021 19:13:04 +0000 (15:13 -0400)
packages/runtime-core/src/componentRenderUtils.ts
packages/runtime-core/src/hydration.ts
packages/runtime-core/src/renderer.ts
packages/runtime-core/src/vnode.ts

index 0563ba592ef058b465ac7e35c57d1bc507d21c9f..79cafc4205c3a1bf4822cdbb6d21ca116be3051d 100644 (file)
@@ -128,10 +128,7 @@ export function renderComponentRoot(
       const keys = Object.keys(fallthroughAttrs)
       const { shapeFlag } = root
       if (keys.length) {
-        if (
-          shapeFlag & ShapeFlags.ELEMENT ||
-          shapeFlag & ShapeFlags.COMPONENT
-        ) {
+        if (shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.COMPONENT)) {
           if (propsOptions && keys.some(isModelListener)) {
             // If a v-model listener (onUpdate:xxx) has a corresponding declared
             // prop, it indicates this component expects to handle v-model and
@@ -186,8 +183,7 @@ export function renderComponentRoot(
       __COMPAT__ &&
       isCompatEnabled(DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE, instance) &&
       vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT &&
-      (root.shapeFlag & ShapeFlags.ELEMENT ||
-        root.shapeFlag & ShapeFlags.COMPONENT)
+      root.shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.COMPONENT)
     ) {
       const { class: cls, style } = vnode.props || {}
       if (cls || style) {
@@ -316,8 +312,7 @@ const filterModelListeners = (attrs: Data, props: NormalizedProps): Data => {
 
 const isElementRoot = (vnode: VNode) => {
   return (
-    vnode.shapeFlag & ShapeFlags.COMPONENT ||
-    vnode.shapeFlag & ShapeFlags.ELEMENT ||
+    vnode.shapeFlag & (ShapeFlags.COMPONENT | ShapeFlags.ELEMENT) ||
     vnode.type === Comment // potential v-if branch switch
   )
 }
index 9b2a903fb54c124292032ccc5925cd4fccd6735b..939cf0ca1de299aadad3648e949ee2d8296b95a8 100644 (file)
@@ -280,8 +280,7 @@ export function createHydrationFunctions(
         if (
           forcePatchValue ||
           !optimized ||
-          patchFlag & PatchFlags.FULL_PROPS ||
-          patchFlag & PatchFlags.HYDRATE_EVENTS
+          patchFlag & (PatchFlags.FULL_PROPS | PatchFlags.HYDRATE_EVENTS)
         ) {
           for (const key in props) {
             if (
index 62db9cd8cb91d864cecc5b96ef15535aae81e173..f1f2f95214dffc200b775478d2001876302f60a6 100644 (file)
@@ -984,8 +984,7 @@ function baseCreateRenderer(
           // which also requires the correct parent container
           !isSameVNodeType(oldVNode, newVNode) ||
           // - In the case of a component, it could contain anything.
-          oldVNode.shapeFlag & ShapeFlags.COMPONENT ||
-          oldVNode.shapeFlag & ShapeFlags.TELEPORT)
+          oldVNode.shapeFlag & (ShapeFlags.COMPONENT | ShapeFlags.TELEPORT))
           ? hostParentNode(oldVNode.el)!
           : // In other cases, the parent container is not actually used so we
             // just pass the block element here to avoid a DOM parentNode call.
@@ -2129,8 +2128,8 @@ function baseCreateRenderer(
         )
       } else if (
         (type === Fragment &&
-          (patchFlag & PatchFlags.KEYED_FRAGMENT ||
-            patchFlag & PatchFlags.UNKEYED_FRAGMENT)) ||
+          patchFlag &
+            (PatchFlags.KEYED_FRAGMENT | PatchFlags.UNKEYED_FRAGMENT)) ||
         (!optimized && shapeFlag & ShapeFlags.ARRAY_CHILDREN)
       ) {
         unmountChildren(children as VNode[], parentComponent, parentSuspense)
index 26b2ac9e42316a1fa7ef5d2f5b13daffd80bb1b1..a03fc411527cd02d5e49a8d4ecb200161d41cb6e 100644 (file)
@@ -730,7 +730,7 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
   } else if (isArray(children)) {
     type = ShapeFlags.ARRAY_CHILDREN
   } else if (typeof children === 'object') {
-    if (shapeFlag & ShapeFlags.ELEMENT || shapeFlag & ShapeFlags.TELEPORT) {
+    if (shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.TELEPORT)) {
       // Normalize slot to plain children for plain element and Teleport
       const slot = (children as any).default
       if (slot) {