Skip to content

Commit f129024

Browse files
posvahefeng
authored and
hefeng
committed
fix(codegen): support filters with () in older browsers (vuejs#7545)
Fix vuejs#7544 Make sure no extra , is added at the end of the call so it also work with older browsers
1 parent b9390a9 commit f129024

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/compiler/parser/filter-parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ function wrapFilter (exp: string, filter: string): string {
9292
} else {
9393
const name = filter.slice(0, i)
9494
const args = filter.slice(i + 1)
95-
return `_f("${name}")(${exp},${args}`
95+
return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`
9696
}
9797
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ describe('codegen', () => {
4444
)
4545
})
4646

47+
it('generate filters with no arguments', () => {
48+
assertCodegen(
49+
'<div>{{ d | e() }}</div>',
50+
`with(this){return _c('div',[_v(_s(_f("e")(d)))])}`
51+
)
52+
})
53+
4754
it('generate v-for directive', () => {
4855
assertCodegen(
4956
'<div><li v-for="item in items" :key="item.uid"></li></div>',

0 commit comments

Comments
 (0)