Skip to content

Commit 8366126

Browse files
authored
fix(compat): include legacy scoped slots (#10868)
close #8869
1 parent f2c1412 commit 8366126

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

Diff for: packages/runtime-core/src/compat/instance.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ import {
3636
legacyresolveScopedSlots,
3737
} from './renderHelpers'
3838
import { resolveFilter } from '../helpers/resolveAssets'
39-
import type { InternalSlots, Slots } from '../componentSlots'
40-
import type { ContextualRenderFn } from '../componentRenderContext'
39+
import type { Slots } from '../componentSlots'
4140
import { resolveMergedOptions } from '../componentOptions'
4241

4342
export type LegacyPublicInstance = ComponentPublicInstance &
@@ -106,14 +105,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
106105

107106
$scopedSlots: i => {
108107
assertCompatEnabled(DeprecationTypes.INSTANCE_SCOPED_SLOTS, i)
109-
const res: InternalSlots = {}
110-
for (const key in i.slots) {
111-
const fn = i.slots[key]!
112-
if (!(fn as ContextualRenderFn)._ns /* non-scoped slot */) {
113-
res[key] = fn
114-
}
115-
}
116-
return res
108+
return __DEV__ ? shallowReadonly(i.slots) : i.slots
117109
},
118110

119111
$on: i => on.bind(null, i),

Diff for: packages/vue-compat/__tests__/instance.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
284284
).toHaveBeenWarned()
285285
})
286286

287-
test('should not include legacy slot usage in $scopedSlots', () => {
287+
test('should include legacy slot usage in $scopedSlots', () => {
288288
let normalSlots: Slots
289289
let scopedSlots: Slots
290290
new Vue({
@@ -301,7 +301,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
301301
}).$mount()
302302

303303
expect('default' in normalSlots!).toBe(true)
304-
expect('default' in scopedSlots!).toBe(false)
304+
expect('default' in scopedSlots!).toBe(true)
305305

306306
expect(
307307
deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message,

0 commit comments

Comments
 (0)