Browse Source

fix(compiler-core): should alias name in helperString (#743)

fix #740
likui 6 years ago
parent
commit
7b987d9450

+ 1 - 1
packages/compiler-core/__tests__/transforms/vBind.spec.ts

@@ -137,7 +137,7 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         children: [
-          `${helperNameMap[CAMELIZE]}(`,
+          `_${helperNameMap[CAMELIZE]}(`,
           { content: `_ctx.foo` },
           `(`,
           { content: `_ctx.bar` },

+ 1 - 4
packages/compiler-core/src/transform.ts

@@ -161,10 +161,7 @@ export function createTransformContext(
       return name
     },
     helperString(name) {
-      return (
-        (context.prefixIdentifiers ? `` : `_`) +
-        helperNameMap[context.helper(name)]
-      )
+      return `_${helperNameMap[context.helper(name)]}`
     },
     replaceNode(node) {
       /* istanbul ignore if */

+ 0 - 1
packages/compiler-core/src/transforms/transformElement.ts

@@ -517,7 +517,6 @@ function buildDirectiveArgs(
   const dirArgs: ArrayExpression['elements'] = []
   const runtime = directiveImportMap.get(dir)
   if (runtime) {
-    context.helper(runtime)
     dirArgs.push(context.helperString(runtime))
   } else {
     // inject statement for resolving directive