]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler): include createTextVNode helper for hoisted static content (fix #465)
authorEvan You <yyx990803@gmail.com>
Mon, 18 Nov 2019 02:26:25 +0000 (21:26 -0500)
committerEvan You <yyx990803@gmail.com>
Mon, 18 Nov 2019 02:26:25 +0000 (21:26 -0500)
packages/compiler-core/src/codegen.ts

index 8baff9cb396914a9275599fed1e013fda5764fc3..d903d023cb82cd4f9f232d730217b03701ef20c9 100644 (file)
@@ -35,7 +35,8 @@ import {
   RESOLVE_COMPONENT,
   RESOLVE_DIRECTIVE,
   SET_BLOCK_TRACKING,
-  CREATE_COMMENT
+  CREATE_COMMENT,
+  CREATE_TEXT
 } from './runtimeHelpers'
 
 type CodegenNode = TemplateChildNode | JSChildNode
@@ -212,18 +213,11 @@ export function generate(
         // has check cost, but hoists are lifted out of the function - we need
         // to provide the helper here.
         if (ast.hoists.length) {
-          push(
-            `const _${helperNameMap[CREATE_VNODE]} = Vue.${
-              helperNameMap[CREATE_VNODE]
-            }\n`
-          )
-          if (ast.helpers.includes(CREATE_COMMENT)) {
-            push(
-              `const _${helperNameMap[CREATE_COMMENT]} = Vue.${
-                helperNameMap[CREATE_COMMENT]
-              }\n`
-            )
-          }
+          const staticHelpers = [CREATE_VNODE, CREATE_COMMENT, CREATE_TEXT]
+            .filter(helper => ast.helpers.includes(helper))
+            .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
+            .join(', ')
+          push(`const { ${staticHelpers} } = Vue\n`)
         }
       }
     }