From 9d26a16fb6b886929c86a36cc999e8d706a0809e Mon Sep 17 00:00:00 2001 From: Stanislav Lashmanov Date: Mon, 6 May 2024 06:28:41 +0400 Subject: [PATCH 1/3] fix(compat): include legacy scoped slots close https://github.com/vuejs/core/issues/8869 --- packages/runtime-core/src/compat/instance.ts | 5 +---- packages/vue-compat/__tests__/instance.spec.ts | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/runtime-core/src/compat/instance.ts b/packages/runtime-core/src/compat/instance.ts index d310de49ae6..0523595a285 100644 --- a/packages/runtime-core/src/compat/instance.ts +++ b/packages/runtime-core/src/compat/instance.ts @@ -37,7 +37,6 @@ import { } from './renderHelpers' import { resolveFilter } from '../helpers/resolveAssets' import type { InternalSlots, Slots } from '../componentSlots' -import type { ContextualRenderFn } from '../componentRenderContext' import { resolveMergedOptions } from '../componentOptions' export type LegacyPublicInstance = ComponentPublicInstance & @@ -109,9 +108,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) { 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 - } + res[key] = fn } return res }, 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, From 25a7235db409bea0b2b99af9bc1d0ac121e4e1e1 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 7 May 2024 06:45:30 +0800 Subject: [PATCH 2/3] Update instance.ts --- packages/runtime-core/src/compat/instance.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/runtime-core/src/compat/instance.ts b/packages/runtime-core/src/compat/instance.ts index 0523595a285..6ae2a3ff809 100644 --- a/packages/runtime-core/src/compat/instance.ts +++ b/packages/runtime-core/src/compat/instance.ts @@ -105,12 +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]! - res[key] = fn - } - return res + return __DEV__ ? shallowReadonly(i.slots) : i.slots }, $on: i => on.bind(null, i), From f975f4cd8738d2a26efb41a67f1848a351d868e2 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 7 May 2024 06:49:38 +0800 Subject: [PATCH 3/3] Update instance.ts --- packages/runtime-core/src/compat/instance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/compat/instance.ts b/packages/runtime-core/src/compat/instance.ts index 6ae2a3ff809..18e745ca4e8 100644 --- a/packages/runtime-core/src/compat/instance.ts +++ b/packages/runtime-core/src/compat/instance.ts @@ -36,7 +36,7 @@ import { legacyresolveScopedSlots, } from './renderHelpers' import { resolveFilter } from '../helpers/resolveAssets' -import type { InternalSlots, Slots } from '../componentSlots' +import type { Slots } from '../componentSlots' import { resolveMergedOptions } from '../componentOptions' export type LegacyPublicInstance = ComponentPublicInstance &