fix(compat): include legacy scoped slots (#10868)

close #8869
This commit is contained in:
Stanislav Lashmanov 2024-05-07 03:05:55 +04:00 committed by GitHub
parent f2c1412e46
commit 83661264a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 12 deletions

View File

@ -36,8 +36,7 @@ import {
legacyresolveScopedSlots,
} from './renderHelpers'
import { resolveFilter } from '../helpers/resolveAssets'
import type { InternalSlots, Slots } from '../componentSlots'
import type { ContextualRenderFn } from '../componentRenderContext'
import type { Slots } from '../componentSlots'
import { resolveMergedOptions } from '../componentOptions'
export type LegacyPublicInstance = ComponentPublicInstance &
@ -106,14 +105,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
$scopedSlots: i => {
assertCompatEnabled(DeprecationTypes.INSTANCE_SCOPED_SLOTS, i)
const res: InternalSlots = {}
for (const key in i.slots) {
const fn = i.slots[key]!
if (!(fn as ContextualRenderFn)._ns /* non-scoped slot */) {
res[key] = fn
}
}
return res
return __DEV__ ? shallowReadonly(i.slots) : i.slots
},
$on: i => on.bind(null, i),

View File

@ -284,7 +284,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
).toHaveBeenWarned()
})
test('should not include legacy slot usage in $scopedSlots', () => {
test('should include legacy slot usage in $scopedSlots', () => {
let normalSlots: Slots
let scopedSlots: Slots
new Vue({
@ -301,7 +301,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
}).$mount()
expect('default' in normalSlots!).toBe(true)
expect('default' in scopedSlots!).toBe(false)
expect('default' in scopedSlots!).toBe(true)
expect(
deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message,