@@ -180,6 +180,22 @@ return function render(_ctx, _cache) {
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: v-for codegen v-if + v-for on <template> 1`] = `
|
||||
"const _Vue = Vue
|
||||
|
||||
return function render(_ctx, _cache) {
|
||||
with (_ctx) {
|
||||
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
|
||||
|
||||
return ok
|
||||
? (_openBlock(true), _createBlock(_Fragment, { key: 0 }, _renderList(list, (i) => {
|
||||
return (_openBlock(), _createBlock(_Fragment, null, [], 64 /* STABLE_FRAGMENT */))
|
||||
}), 256 /* UNKEYED_FRAGMENT */))
|
||||
: _createCommentVNode(\\"v-if\\", true)
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: v-for codegen value + key + index 1`] = `
|
||||
"const _Vue = Vue
|
||||
|
||||
|
||||
@@ -840,6 +840,44 @@ describe('compiler: v-for', () => {
|
||||
expect(generate(root).code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
// 1637
|
||||
test('v-if + v-for on <template>', () => {
|
||||
const {
|
||||
root,
|
||||
node: { codegenNode }
|
||||
} = parseWithForTransform(`<template v-if="ok" v-for="i in list"/>`)
|
||||
expect(codegenNode).toMatchObject({
|
||||
type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
|
||||
test: { content: `ok` },
|
||||
consequent: {
|
||||
type: NodeTypes.VNODE_CALL,
|
||||
props: createObjectMatcher({
|
||||
key: `[0]`
|
||||
}),
|
||||
isBlock: true,
|
||||
disableTracking: true,
|
||||
patchFlag: genFlagText(PatchFlags.UNKEYED_FRAGMENT),
|
||||
children: {
|
||||
type: NodeTypes.JS_CALL_EXPRESSION,
|
||||
callee: RENDER_LIST,
|
||||
arguments: [
|
||||
{ content: `list` },
|
||||
{
|
||||
type: NodeTypes.JS_FUNCTION_EXPRESSION,
|
||||
params: [{ content: `i` }],
|
||||
returns: {
|
||||
type: NodeTypes.VNODE_CALL,
|
||||
tag: FRAGMENT,
|
||||
isBlock: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(generate(root).code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('v-for on element with custom directive', () => {
|
||||
const {
|
||||
root,
|
||||
|
||||
Reference in New Issue
Block a user