Skip to content
Permalink
Browse files
fix(compiler): fix codegen for v-for component inside template
fix #9142
  • Loading branch information
yyx990803 committed Dec 4, 2018
1 parent 448ba65 commit 1b4a8a0c1edaf9c7eb129ba61bca94ba607bbf56
Showing with 9 additions and 3 deletions.
  1. +1 鈭3 src/compiler/codegen/index.js
  2. +8 鈭0 test/unit/modules/compiler/codegen.spec.js
@@ -406,9 +406,7 @@ export function genChildren (
el.tag !== 'template' &&
el.tag !== 'slot'
) {
// because el may be a functional component and return an Array instead of a single root.
// In this case, just a simple normalization is needed
const normalizationType = state.maybeComponent(el) ? `,1` : ``
const normalizationType = checkSkip && state.maybeComponent(el) ? `,1` : ``
return `${(altGenElement || genElement)(el, state)}${normalizationType}`
}
const normalizationType = checkSkip
@@ -631,5 +631,13 @@ describe('codegen', () => {
{ isReservedTag }
)
})

// #9142
it('should compile single v-for component inside template', () => {
assertCodegen(
`<div><template v-if="ok"><foo v-for="i in 1" :key="i"></foo></template></div>`,
`with(this){return _c('div',[(ok)?_l((1),function(i){return _c('foo',{key:i})}):_e()],2)}`
)
})
})
/* eslint-enable quotes */

0 comments on commit 1b4a8a0

Please sign in to comment.