فهرست منبع

expose expression on directive binding

Evan You 10 سال پیش
والد
کامیت
8d2ee3c1f8
2فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 1 1
      src/compiler/codegen.js
  2. 2 2
      test/unit/modules/compiler/codegen.spec.js

+ 1 - 1
src/compiler/codegen.js

@@ -206,7 +206,7 @@ function genDirectives (el: ASTElement): string | void {
     if (needRuntime) {
       hasRuntime = true
       res += `{name:"${dir.name}"${
-        dir.value ? `,value:(${dir.value})` : ''
+        dir.value ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}` : ''
       }${
         dir.arg ? `,arg:"${dir.arg}"` : ''
       }${

+ 2 - 2
test/unit/modules/compiler/codegen.spec.js

@@ -34,7 +34,7 @@ describe('codegen', () => {
   it('generate directive', () => {
     assertCodegen(
       '<p v-custom1:arg1.modifire="value1" v-custom2><p>',
-      `with(this){return _h(_e('p',{directives:[{name:"custom1",value:(value1),arg:"arg1",modifiers:{"modifire":true}},{name:"custom2",arg:"arg1"}]}))}`
+      `with(this){return _h(_e('p',{directives:[{name:"custom1",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifire":true}},{name:"custom2",arg:"arg1"}]}))}`
     )
   })
 
@@ -180,7 +180,7 @@ describe('codegen', () => {
   it('generate v-show directive', () => {
     assertCodegen(
       '<p v-show="shown">hello world</p>',
-      `with(this){return _h(_e('p',{directives:[{name:"show",value:(shown)}],show:true}),[_t("hello world")])}`
+      `with(this){return _h(_e('p',{directives:[{name:"show",value:(shown),expression:"shown"}],show:true}),[_t("hello world")])}`
     )
   })