From f490846cc98197ef20a620ee71fbf444cbe6a90d Mon Sep 17 00:00:00 2001 From: Stanislav Lashmanov Date: Tue, 7 May 2024 03:05:55 +0400 Subject: [PATCH] fix(compat): include legacy scoped slots (#10868) close #8869 --- packages/runtime-core/src/compat/instance.ts | 12 ++---------- packages/vue-compat/__tests__/instance.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/runtime-core/src/compat/instance.ts b/packages/runtime-core/src/compat/instance.ts index d310de49ae6..18e745ca4e8 100644 --- a/packages/runtime-core/src/compat/instance.ts +++ b/packages/runtime-core/src/compat/instance.ts @@ -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), diff --git a/packages/vue-compat/__tests__/instance.spec.ts b/packages/vue-compat/__tests__/instance.spec.ts index 1feccabd8f8..75f1ea1334c 100644 --- a/packages/vue-compat/__tests__/instance.spec.ts +++ b/packages/vue-compat/__tests__/instance.spec.ts @@ -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,