@@ -20,6 +20,7 @@ import { isKeepAlive } from './components/KeepAlive'
20
20
import { withCtx } from './componentRenderContext'
21
21
import { isHmrUpdating } from './hmr'
22
22
import { DeprecationTypes , isCompatEnabled } from './compat/compatConfig'
23
+ import { toRaw } from '@vue/reactivity'
23
24
24
25
export type Slot = ( ...args : any [ ] ) => VNode [ ]
25
26
@@ -62,7 +63,8 @@ const normalizeSlot = (
62
63
rawSlot : Function ,
63
64
ctx : ComponentInternalInstance | null | undefined
64
65
) : Slot =>
65
- withCtx ( ( props : any ) => {
66
+ ( rawSlot as any ) . _c ||
67
+ ( withCtx ( ( props : any ) => {
66
68
if ( __DEV__ && currentInstance ) {
67
69
warn (
68
70
`Slot "${ key } " invoked outside of the render function: ` +
@@ -71,7 +73,7 @@ const normalizeSlot = (
71
73
)
72
74
}
73
75
return normalizeSlotValue ( rawSlot ( props ) )
74
- } , ctx ) as Slot
76
+ } , ctx ) as Slot )
75
77
76
78
const normalizeObjectSlots = (
77
79
rawSlots : RawSlots ,
@@ -128,7 +130,9 @@ export const initSlots = (
128
130
if ( instance . vnode . shapeFlag & ShapeFlags . SLOTS_CHILDREN ) {
129
131
const type = ( children as RawSlots ) . _
130
132
if ( type ) {
131
- instance . slots = children as InternalSlots
133
+ // users can get the shallow readonly version of the slots object through `this.$slots`,
134
+ // we should avoid the proxy object polluting the slots of the internal instance
135
+ instance . slots = toRaw ( children as InternalSlots )
132
136
// make compiler marker non-enumerable
133
137
def ( children as InternalSlots , '_' , type )
134
138
} else {
0 commit comments