wip: exclude legacy slots from $scopedSlots

This commit is contained in:
Evan You
2021-05-05 11:06:04 -04:00
parent b14de6c3f8
commit 7f93c76b96
7 changed files with 80 additions and 28 deletions

View File

@@ -251,30 +251,56 @@ test('INSTANCE_LISTENERS', () => {
).toHaveBeenWarned()
})
test('INSTANCE_SCOPED_SLOTS', () => {
let slots: Slots
new Vue({
template: `<child v-slot="{ msg }">{{ msg }}</child>`,
components: {
child: {
compatConfig: { RENDER_FUNCTION: false },
render() {
slots = this.$scopedSlots
describe('INSTANCE_SCOPED_SLOTS', () => {
test('explicit usage', () => {
let slots: Slots
new Vue({
template: `<child v-slot="{ msg }">{{ msg }}</child>`,
components: {
child: {
compatConfig: { RENDER_FUNCTION: false },
render() {
slots = this.$scopedSlots
}
}
}
}
}).$mount()
}).$mount()
expect(slots!.default!({ msg: 'hi' })).toMatchObject([
{
type: Text,
children: 'hi'
}
])
expect(slots!.default!({ msg: 'hi' })).toMatchObject([
{
type: Text,
children: 'hi'
}
])
expect(
deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message
).toHaveBeenWarned()
expect(
deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message
).toHaveBeenWarned()
})
test('should not include legacy slot usage in $scopedSlots', () => {
let normalSlots: Slots
let scopedSlots: Slots
new Vue({
template: `<child><div>default</div></child>`,
components: {
child: {
compatConfig: { RENDER_FUNCTION: false },
render() {
normalSlots = this.$slots
scopedSlots = this.$scopedSlots
}
}
}
}).$mount()
expect('default' in normalSlots!).toBe(true)
expect('default' in scopedSlots!).toBe(false)
expect(
deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message
).toHaveBeenWarned()
})
})
test('INSTANCE_ATTR_CLASS_STYLE', () => {