Skip to content

Commit e7dfcc3

Browse files
committed
fix custom directive arg fall through (fix vuejs#5162)
1 parent 0b964c8 commit e7dfcc3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/compiler/parser/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ function processComponent (el) {
427427

428428
function processAttrs (el) {
429429
const list = el.attrsList
430-
let i, l, name, rawName, value, arg, modifiers, isProp
430+
let i, l, name, rawName, value, modifiers, isProp
431431
for (i = 0, l = list.length; i < l; i++) {
432432
name = rawName = list[i].name
433433
value = list[i].value
@@ -465,7 +465,8 @@ function processAttrs (el) {
465465
name = name.replace(dirRE, '')
466466
// parse arg
467467
const argMatch = name.match(argRE)
468-
if (argMatch && (arg = argMatch[1])) {
468+
const arg = argMatch && argMatch[1]
469+
if (arg) {
469470
name = name.slice(0, -(arg.length + 1))
470471
}
471472
addDirective(el, name, rawName, value, arg, modifiers)

test/unit/modules/compiler/codegen.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('codegen', () => {
3333
it('generate directive', () => {
3434
assertCodegen(
3535
'<p v-custom1:arg1.modifier="value1" v-custom2></p>',
36-
`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"}]})}`
36+
`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"}]})}`
3737
)
3838
})
3939

0 commit comments

Comments
 (0)