From e7dfcc334d6f6513d2ed1cddfa28a08796e07df7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 10 Mar 2017 15:55:31 +0800 Subject: [PATCH] fix custom directive arg fall through (fix #5162) --- src/compiler/parser/index.js | 5 +++-- test/unit/modules/compiler/codegen.spec.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index 2db7a9679..ff474ccc9 100644 --- a/src/compiler/parser/index.js +++ b/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) diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js index ba4374cbd..f97dd1c4a 100644 --- a/test/unit/modules/compiler/codegen.spec.js +++ b/test/unit/modules/compiler/codegen.spec.js @@ -33,7 +33,7 @@ describe('codegen', () => { it('generate directive', () => { assertCodegen( '

', - `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"}]})}` ) })