Skip to content

Commit 7688d05

Browse files
authored
Merge branch 'main' into fix-slots-level
2 parents 80a54dd + 07444b3 commit 7688d05

17 files changed

+563
-44
lines changed

packages/runtime-vapor/__tests__/componentSlots.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,40 @@ describe('component: slots', () => {
158158
})
159159

160160
test('the current instance should be kept in the slot', async () => {
161+
let instanceInDefaultSlot: any
162+
let instanceInFooSlot: any
163+
164+
const Comp = defineComponent({
165+
render() {
166+
const instance = getCurrentInstance()
167+
instance!.slots.default!()
168+
instance!.slots.foo!()
169+
return template('<div></div>')()
170+
},
171+
})
172+
173+
const { instance } = define({
174+
render() {
175+
return createComponent(Comp, {}, [
176+
{
177+
default: () => {
178+
instanceInDefaultSlot = getCurrentInstance()
179+
return template('content')()
180+
},
181+
foo: () => {
182+
instanceInFooSlot = getCurrentInstance()
183+
return template('content')()
184+
},
185+
},
186+
])
187+
},
188+
}).render()
189+
190+
expect(instanceInDefaultSlot).toBe(instance)
191+
expect(instanceInFooSlot).toBe(instance)
192+
})
193+
194+
test('the current instance should be kept in the dynamic slots', async () => {
161195
let instanceInDefaultSlot: any
162196
let instanceInVForSlot: any
163197
let instanceInVIfSlot: any

0 commit comments

Comments
 (0)