Skip to content

Commit

Permalink
fix(compat): include legacy scoped slots (#10868)
Browse files Browse the repository at this point in the history
close #8869
  • Loading branch information
CyberAP authored May 6, 2024
1 parent f2c1412 commit 8366126
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions packages/runtime-core/src/compat/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-compat/__tests__/instance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand Down

0 comments on commit 8366126

Please sign in to comment.