Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compat): include legacy scoped slots #10868

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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