fix(runtime-core): avoid manual slot invocation in template expressions interfering with block tracking
fix #1745
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { renderSlot } from '../../src/helpers/renderSlot'
|
||||
import { h } from '../../src/h'
|
||||
import {
|
||||
h,
|
||||
withCtx,
|
||||
createVNode,
|
||||
openBlock,
|
||||
createBlock,
|
||||
Fragment
|
||||
} from '../../src'
|
||||
import { PatchFlags } from '@vue/shared/src'
|
||||
|
||||
describe('renderSlot', () => {
|
||||
it('should render slot', () => {
|
||||
@@ -20,4 +28,23 @@ describe('renderSlot', () => {
|
||||
renderSlot({ default: (_a, _b, _c) => [h('child')] }, 'default')
|
||||
expect('SSR-optimized slot function detected').toHaveBeenWarned()
|
||||
})
|
||||
|
||||
// #1745
|
||||
it('should force enable tracking', () => {
|
||||
const slot = withCtx(
|
||||
() => {
|
||||
return [createVNode('div', null, 'foo', PatchFlags.TEXT)]
|
||||
},
|
||||
// mock instance
|
||||
{} as any
|
||||
)
|
||||
|
||||
// manual invocation should not track
|
||||
const manual = (openBlock(), createBlock(Fragment, null, slot()))
|
||||
expect(manual.dynamicChildren!.length).toBe(0)
|
||||
|
||||
// renderSlot should track
|
||||
const templateRendered = renderSlot({ default: slot }, 'default')
|
||||
expect(templateRendered.dynamicChildren!.length).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user