chore: fix all test cases

This commit is contained in:
Evan You 2021-03-05 16:07:23 -05:00
parent 68416e988f
commit ff4d4ec249
6 changed files with 23 additions and 9 deletions

View File

@ -129,7 +129,7 @@ return function render(_ctx, _cache) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, renderSlot: _renderSlot } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
return _renderSlot($slots, \\"default\\")
return _renderSlot($slots, \\"default\\", {}, undefined, true)
}), 256 /* UNKEYED_FRAGMENT */))
}
}"
@ -143,7 +143,7 @@ return function render(_ctx, _cache) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, renderSlot: _renderSlot } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
return _renderSlot($slots, \\"default\\")
return _renderSlot($slots, \\"default\\", {}, undefined, true)
}), 256 /* UNKEYED_FRAGMENT */))
}
}"

View File

@ -80,7 +80,7 @@ return function render(_ctx, _cache) {
const { renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue
return ok
? _renderSlot($slots, \\"default\\", { key: 0 })
? _renderSlot($slots, \\"default\\", { key: 0 }, undefined, true)
: _createCommentVNode(\\"v-if\\", true)
}
}"
@ -140,7 +140,7 @@ return function render(_ctx, _cache) {
const { renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue
return ok
? _renderSlot($slots, \\"default\\", { key: 0 })
? _renderSlot($slots, \\"default\\", { key: 0 }, undefined, true)
: _createCommentVNode(\\"v-if\\", true)
}
}"

View File

@ -67,7 +67,7 @@ return function render(_ctx, _cache) {
return (_openBlock(), _createBlock(\\"div\\", null, [
_cache[1] || (
_setBlockTracking(-1),
_cache[1] = _renderSlot($slots, \\"default\\"),
_cache[1] = _renderSlot($slots, \\"default\\", {}, undefined, true),
_setBlockTracking(1),
_cache[1]
)

View File

@ -16,6 +16,7 @@ import { transformSlotOutlet } from '../../src/transforms/transformSlotOutlet'
function parseWithSlots(template: string, options: CompilerOptions = {}) {
const ast = parse(template)
transform(ast, {
slotted: false,
nodeTransforms: [
...(options.prefixIdentifiers ? [transformExpression] : []),
transformSlotOutlet,

View File

@ -404,7 +404,13 @@ describe('compiler: v-if', () => {
expect(codegenNode.consequent).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
callee: RENDER_SLOT,
arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })]
arguments: [
'$slots',
'"default"',
createObjectMatcher({ key: `[0]` }),
'undefined',
'true'
]
})
expect(generate(root).code).toMatchSnapshot()
})
@ -417,7 +423,13 @@ describe('compiler: v-if', () => {
expect(codegenNode.consequent).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
callee: RENDER_SLOT,
arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })]
arguments: [
'$slots',
'"default"',
createObjectMatcher({ key: `[0]` }),
'undefined',
'true'
]
})
expect(generate(root).code).toMatchSnapshot()
})

View File

@ -6,7 +6,8 @@ import {
openBlock,
createBlock,
Fragment,
createCommentVNode
createCommentVNode,
Slot
} from '../../src'
import { PatchFlags } from '@vue/shared'
@ -38,7 +39,7 @@ describe('renderSlot', () => {
},
// mock instance
{ type: {} } as any
)
) as Slot
// manual invocation should not track
const manual = (openBlock(), createBlock(Fragment, null, slot()))