MCPcopy
hub / github.com/vuejs/core / normalizeSlot

Function normalizeSlot

packages/runtime-core/src/componentSlots.ts:92–119  ·  view source on GitHub ↗
(
  key: string,
  rawSlot: Function,
  ctx: ComponentInternalInstance | null | undefined,
)

Source from the content-addressed store, hash-verified

90 : [normalizeVNode(value as VNodeChild)]
91
92const normalizeSlot = (
93 key: string,
94 rawSlot: Function,
95 ctx: ComponentInternalInstance | null | undefined,
96): Slot => {
97 if ((rawSlot as any)._n) {
98 // already normalized - #5353
99 return rawSlot as Slot
100 }
101 const normalized = withCtx((...args: any[]) => {
102 if (
103 __DEV__ &&
104 currentInstance &&
105 !(ctx === null && currentRenderingInstance) &&
106 !(ctx && ctx.root !== currentInstance.root)
107 ) {
108 warn(
109 `Slot "${key}" invoked outside of the render function: ` +
110 `this will not track dependencies used in the slot. ` +
111 `Invoke the slot function inside the render function instead.`,
112 )
113 }
114 return normalizeSlotValue(rawSlot(...args))
115 }, ctx) as Slot
116 // NOT a compiled slot
117 ;(normalized as ContextualRenderFn)._c = false
118 return normalized
119}
120
121const normalizeObjectSlots = (
122 rawSlots: RawSlots,

Callers 1

normalizeObjectSlotsFunction · 0.85

Calls 3

withCtxFunction · 0.90
warnFunction · 0.90
normalizeSlotValueFunction · 0.85

Tested by

no test coverage detected