Skip to content

Commit cde7f05

Browse files
committedApr 18, 2024··
fix(runtime-core): further fix slots _ctx check
close #10724
1 parent e51ca61 commit cde7f05

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed
 

‎packages/runtime-core/src/componentSlots.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import { isKeepAlive } from './components/KeepAlive'
2121
import { type ContextualRenderFn, withCtx } from './componentRenderContext'
2222
import { isHmrUpdating } from './hmr'
2323
import { DeprecationTypes, isCompatEnabled } from './compat/compatConfig'
24-
import { toRaw } from '@vue/reactivity'
25-
import { trigger } from '@vue/reactivity'
26-
import { TriggerOpTypes } from '@vue/reactivity'
24+
import { TriggerOpTypes, trigger } from '@vue/reactivity'
2725
import { createInternalObject } from './internalObject'
2826

2927
export type Slot<T extends any = any> = (
@@ -167,26 +165,18 @@ export const initSlots = (
167165
instance: ComponentInternalInstance,
168166
children: VNodeNormalizedChildren,
169167
) => {
168+
const slots = (instance.slots = createInternalObject())
170169
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
171170
const type = (children as RawSlots)._
172171
if (type) {
173-
// users can get the shallow readonly version of the slots object through `this.$slots`,
174-
// we should avoid the proxy object polluting the slots of the internal instance
175-
instance.slots = toRaw(children as InternalSlots)
172+
extend(slots, children as InternalSlots)
176173
// make compiler marker non-enumerable
177-
def(instance.slots, '_', type)
174+
def(slots, '_', type)
178175
} else {
179-
normalizeObjectSlots(
180-
children as RawSlots,
181-
(instance.slots = createInternalObject()),
182-
instance,
183-
)
184-
}
185-
} else {
186-
instance.slots = createInternalObject()
187-
if (children) {
188-
normalizeVNodeSlots(instance, children)
176+
normalizeObjectSlots(children as RawSlots, slots, instance)
189177
}
178+
} else if (children) {
179+
normalizeVNodeSlots(instance, children)
190180
}
191181
}
192182

0 commit comments

Comments
 (0)
Please sign in to comment.