Skip to content

Commit

Permalink
fix(codegen): support filters with () in older browsers (vuejs#7545)
Browse files Browse the repository at this point in the history
Fix vuejs#7544
Make sure no extra , is added at the end of the call so it also work with older browsers
  • Loading branch information
posva authored and aJean committed Aug 19, 2020
1 parent 39b6c6a commit c9141b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/parser/filter-parser.js
Expand Up @@ -92,6 +92,6 @@ function wrapFilter (exp: string, filter: string): string {
} else {
const name = filter.slice(0, i)
const args = filter.slice(i + 1)
return `_f("${name}")(${exp},${args}`
return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`
}
}
7 changes: 7 additions & 0 deletions test/unit/modules/compiler/codegen.spec.js
Expand Up @@ -44,6 +44,13 @@ describe('codegen', () => {
)
})

it('generate filters with no arguments', () => {
assertCodegen(
'<div>{{ d | e() }}</div>',
`with(this){return _c('div',[_v(_s(_f("e")(d)))])}`
)
})

it('generate v-for directive', () => {
assertCodegen(
'<div><li v-for="item in items" :key="item.uid"></li></div>',
Expand Down

0 comments on commit c9141b7

Please sign in to comment.