mirror of https://github.com/vuejs/core.git
parent
e51ca61ca0
commit
cde7f05787
|
@ -21,9 +21,7 @@ import { isKeepAlive } from './components/KeepAlive'
|
||||||
import { type ContextualRenderFn, withCtx } from './componentRenderContext'
|
import { type ContextualRenderFn, withCtx } from './componentRenderContext'
|
||||||
import { isHmrUpdating } from './hmr'
|
import { isHmrUpdating } from './hmr'
|
||||||
import { DeprecationTypes, isCompatEnabled } from './compat/compatConfig'
|
import { DeprecationTypes, isCompatEnabled } from './compat/compatConfig'
|
||||||
import { toRaw } from '@vue/reactivity'
|
import { TriggerOpTypes, trigger } from '@vue/reactivity'
|
||||||
import { trigger } from '@vue/reactivity'
|
|
||||||
import { TriggerOpTypes } from '@vue/reactivity'
|
|
||||||
import { createInternalObject } from './internalObject'
|
import { createInternalObject } from './internalObject'
|
||||||
|
|
||||||
export type Slot<T extends any = any> = (
|
export type Slot<T extends any = any> = (
|
||||||
|
@ -167,27 +165,19 @@ export const initSlots = (
|
||||||
instance: ComponentInternalInstance,
|
instance: ComponentInternalInstance,
|
||||||
children: VNodeNormalizedChildren,
|
children: VNodeNormalizedChildren,
|
||||||
) => {
|
) => {
|
||||||
|
const slots = (instance.slots = createInternalObject())
|
||||||
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
|
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
|
||||||
const type = (children as RawSlots)._
|
const type = (children as RawSlots)._
|
||||||
if (type) {
|
if (type) {
|
||||||
// users can get the shallow readonly version of the slots object through `this.$slots`,
|
extend(slots, children as InternalSlots)
|
||||||
// we should avoid the proxy object polluting the slots of the internal instance
|
|
||||||
instance.slots = toRaw(children as InternalSlots)
|
|
||||||
// make compiler marker non-enumerable
|
// make compiler marker non-enumerable
|
||||||
def(instance.slots, '_', type)
|
def(slots, '_', type)
|
||||||
} else {
|
} else {
|
||||||
normalizeObjectSlots(
|
normalizeObjectSlots(children as RawSlots, slots, instance)
|
||||||
children as RawSlots,
|
|
||||||
(instance.slots = createInternalObject()),
|
|
||||||
instance,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else if (children) {
|
||||||
instance.slots = createInternalObject()
|
|
||||||
if (children) {
|
|
||||||
normalizeVNodeSlots(instance, children)
|
normalizeVNodeSlots(instance, children)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateSlots = (
|
export const updateSlots = (
|
||||||
|
|
Loading…
Reference in New Issue