Skip to content

Commit 47ee6ab

Browse files
committed
remove codegen v-for truthiness check (fix #3817)
1 parent 6d4bdb5 commit 47ee6ab

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/compiler/codegen/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function genFor (el: any): string {
8989
const iterator1 = el.iterator1 ? `,${el.iterator1}` : ''
9090
const iterator2 = el.iterator2 ? `,${el.iterator2}` : ''
9191
el.forProcessed = true // avoid recursion
92-
return `(${exp})&&_l((${exp}),` +
92+
return `_l((${exp}),` +
9393
`function(${alias}${iterator1}${iterator2}){` +
9494
`return ${genElement(el)}` +
9595
'})'

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ describe('codegen', () => {
4040
it('generate v-for directive', () => {
4141
assertCodegen(
4242
'<li v-for="item in items" :key="item.uid"></li>',
43-
`with(this){return (items)&&_l((items),function(item){return _h('li',{key:item.uid})})}`
43+
`with(this){return _l((items),function(item){return _h('li',{key:item.uid})})}`
4444
)
4545
// iterator syntax
4646
assertCodegen(
4747
'<li v-for="(item, i) in items"></li>',
48-
`with(this){return (items)&&_l((items),function(item,i){return _h('li')})}`
48+
`with(this){return _l((items),function(item,i){return _h('li')})}`
4949
)
5050
assertCodegen(
5151
'<li v-for="(item, key, index) in items"></li>',
52-
`with(this){return (items)&&_l((items),function(item,key,index){return _h('li')})}`
52+
`with(this){return _l((items),function(item,key,index){return _h('li')})}`
5353
)
5454
})
5555

@@ -77,7 +77,7 @@ describe('codegen', () => {
7777
it('generate ref on v-for', () => {
7878
assertCodegen(
7979
'<ul><li v-for="item in items" ref="component1"></li></ul>',
80-
`with(this){return _h('ul',[(items)&&_l((items),function(item){return _h('li',{ref:"component1",refInFor:true})})])}`
80+
`with(this){return _h('ul',[_l((items),function(item){return _h('li',{ref:"component1",refInFor:true})})])}`
8181
)
8282
})
8383

@@ -304,7 +304,7 @@ describe('codegen', () => {
304304
it('generate static trees inside v-for', () => {
305305
assertCodegen(
306306
`<div><div v-for="i in 10"><span></span></div></div>`,
307-
`with(this){return _h('div',[(10)&&_l((10),function(i){return _h('div',[_m(0,true)])})])}`,
307+
`with(this){return _h('div',[_l((10),function(i){return _h('div',[_m(0,true)])})])}`,
308308
[`with(this){return _h('span')}`]
309309
)
310310
})

0 commit comments

Comments
 (0)