fix custom directive arg fall through (fix #5162)

This commit is contained in:
Evan You 2017-03-10 15:55:31 +08:00
parent 0b964c8440
commit e7dfcc334d
2 changed files with 4 additions and 3 deletions

View File

@ -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)

View File

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