]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(core): generate fragment root with patchFlag + optimize fragment w/ patchFlag
authorEvan You <yyx990803@gmail.com>
Thu, 12 Dec 2019 22:58:32 +0000 (17:58 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 13 Dec 2019 02:09:47 +0000 (21:09 -0500)
packages/compiler-core/src/transform.ts
packages/compiler-core/src/transforms/vFor.ts
packages/runtime-core/src/renderer.ts

index 0c01cd841a48bddefb3bab60a47bbb7a79185b77..dfa73edc3e607ac51be0790ca178aaf32ee04094 100644 (file)
@@ -18,7 +18,13 @@ import {
   CacheExpression,
   createCacheExpression
 } from './ast'
-import { isString, isArray, NOOP } from '@vue/shared'
+import {
+  isString,
+  isArray,
+  NOOP,
+  PatchFlags,
+  PatchFlagNames
+} from '@vue/shared'
 import { defaultOnError } from './errors'
 import {
   TO_STRING,
@@ -283,7 +289,10 @@ function finalizeRoot(root: RootNode, context: TransformContext) {
       createCallExpression(helper(CREATE_BLOCK), [
         helper(FRAGMENT),
         `null`,
-        root.children
+        root.children,
+        `${PatchFlags.UNKEYED_FRAGMENT} /* ${
+          PatchFlagNames[PatchFlags.UNKEYED_FRAGMENT]
+        } */`
       ]),
       context
     )
index c09a19f1ee62bc09a53865e07d90f92f40705be4..418999cbc1fc9b5b99c31e6796e7a4e06af6dfb6 100644 (file)
@@ -79,7 +79,7 @@ export const transformFor = createStructuralDirectiveTransform(
         helper(FRAGMENT),
         `null`,
         renderExp,
-        fragmentFlag + (__DEV__ ? ` /* ${PatchFlagNames[fragmentFlag]} */` : ``)
+        `${fragmentFlag} /* ${PatchFlagNames[fragmentFlag]} */`
       ])
     ]) as ForCodegenNode
 
index b688525ddc6710afcd3b09b26fbe0dd87ef41e2a..d3c38c3dc3882c7660038fea70719446d5b5fbb0 100644 (file)
@@ -1033,6 +1033,7 @@ export function createRenderer<
     }
     // fast path
     if (patchFlag > 0) {
+      optimized = true
       if (patchFlag & PatchFlags.KEYED_FRAGMENT) {
         // this could be either fully-keyed or mixed (some keyed some not)
         // presence of patchFlag means children are guaranteed to be arrays