Просмотр исходного кода

fix custom directive arg fall through (fix #5162)

Evan You 9 лет назад
Родитель
Сommit
e7dfcc334d
2 измененных файлов с 4 добавлено и 3 удалено
  1. 3 2
      src/compiler/parser/index.js
  2. 1 1
      test/unit/modules/compiler/codegen.spec.js

+ 3 - 2
src/compiler/parser/index.js

@@ -427,7 +427,7 @@ function processComponent (el) {
 
 function processAttrs (el) {
   const list = el.attrsList
-  let i, l, name, rawName, value, arg, modifiers, isProp
+  let i, l, name, rawName, value, modifiers, isProp
   for (i = 0, l = list.length; i < l; i++) {
     name = rawName = list[i].name
     value = list[i].value
@@ -465,7 +465,8 @@ function processAttrs (el) {
         name = name.replace(dirRE, '')
         // parse arg
         const argMatch = name.match(argRE)
-        if (argMatch && (arg = argMatch[1])) {
+        const arg = argMatch && argMatch[1]
+        if (arg) {
           name = name.slice(0, -(arg.length + 1))
         }
         addDirective(el, name, rawName, value, arg, modifiers)

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

@@ -33,7 +33,7 @@ describe('codegen', () => {
   it('generate directive', () => {
     assertCodegen(
       '<p v-custom1:arg1.modifier="value1" v-custom2></p>',
-      `with(this){return _c('p',{directives:[{name:"custom1",rawName:"v-custom1:arg1.modifier",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifier":true}},{name:"custom2",rawName:"v-custom2",arg:"arg1"}]})}`
+      `with(this){return _c('p',{directives:[{name:"custom1",rawName:"v-custom1:arg1.modifier",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifier":true}},{name:"custom2",rawName:"v-custom2"}]})}`
     )
   })