wip: exclude legacy slots from $scopedSlots
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@ export const withScopeId = (_id: string) => withCtx
|
||||
*/
|
||||
export function withCtx(
|
||||
fn: Function,
|
||||
ctx: ComponentInternalInstance | null = currentRenderingInstance
|
||||
ctx: ComponentInternalInstance | null = currentRenderingInstance,
|
||||
isNonScopedSlot?: boolean // __COMPAT__ only
|
||||
) {
|
||||
if (!ctx) return fn
|
||||
const renderFnWithContext = (...args: any[]) => {
|
||||
@@ -83,5 +84,8 @@ export function withCtx(
|
||||
// this is used in vnode.ts -> normalizeChildren() to set the slot
|
||||
// rendering flag.
|
||||
renderFnWithContext._c = true
|
||||
if (__COMPAT__ && isNonScopedSlot) {
|
||||
renderFnWithContext._nonScoped = true
|
||||
}
|
||||
return renderFnWithContext
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user