Skip to content

Commit

Permalink
fix(compat): include legacy scoped slots (vuejs#10868)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberAP authored and lynxlangya committed May 30, 2024
1 parent 7feb523 commit f490846
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 f490846

Please sign in to comment.