wip: exclude legacy slots from $scopedSlots

This commit is contained in:
Evan You
2021-05-05 11:06:04 -04:00
parent b14de6c3f8
commit 7f93c76b96
7 changed files with 80 additions and 28 deletions

View File

@@ -36,7 +36,7 @@ import {
} from './renderHelpers'
import { resolveFilter } from '../helpers/resolveAssets'
import { resolveMergedOptions } from '../componentOptions'
import { Slots } from '../componentSlots'
import { InternalSlots, Slots } from '../componentSlots'
export type LegacyPublicInstance = ComponentPublicInstance &
LegacyPublicProperties
@@ -103,7 +103,14 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
$scopedSlots: i => {
assertCompatEnabled(DeprecationTypes.INSTANCE_SCOPED_SLOTS, i)
return __DEV__ ? shallowReadonly(i.slots) : i.slots
const res: InternalSlots = {}
for (const key in i.slots) {
const fn = i.slots[key]!
if (!(fn as any)._nonScoped) {
res[key] = fn
}
}
return res
},
$on: i => on.bind(null, i),

View File

@@ -281,6 +281,7 @@ function convertLegacySlots(vnode: VNode): VNode {
for (const key in slots) {
const slotChildren = slots[key]
slots[key] = () => slotChildren
slots[key]._nonScoped = true
}
}
}