]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compat): include legacy scoped slots (#10868)
authorStanislav Lashmanov <stasvarenkin@gmail.com>
Mon, 6 May 2024 23:05:55 +0000 (03:05 +0400)
committerGitHub <noreply@github.com>
Mon, 6 May 2024 23:05:55 +0000 (07:05 +0800)
close #8869

packages/runtime-core/src/compat/instance.ts
packages/vue-compat/__tests__/instance.spec.ts

index d310de49ae64a8752e35107b689879a700629252..18e745ca4e86d33e43eb542b89ddea36dcb940dd 100644 (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),
index 1feccabd8f820bc3c7f67ec9a31a038adf7102a3..75f1ea1334c86666e55c46f55486bf486f8c98ea 100644 (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,