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

Function createSlots

packages/runtime-core/src/helpers/createSlots.ts:17–46  ·  view source on GitHub ↗
(
  slots: Record<string, SSRSlot>,
  dynamicSlots: (
    | CompiledSlotDescriptor
    | CompiledSlotDescriptor[]
    | undefined
  )[],
)

Source from the content-addressed store, hash-verified

15 * @private
16 */
17export function createSlots(
18 slots: Record<string, SSRSlot>,
19 dynamicSlots: (
20 | CompiledSlotDescriptor
21 | CompiledSlotDescriptor[]
22 | undefined
23 )[],
24): Record<string, SSRSlot> {
25 for (let i = 0; i < dynamicSlots.length; i++) {
26 const slot = dynamicSlots[i]
27 // array of dynamic slot generated by <template v-for="..." #[...]>
28 if (isArray(slot)) {
29 for (let j = 0; j < slot.length; j++) {
30 slots[slot[j].name] = slot[j].fn
31 }
32 } else if (slot) {
33 // conditional single slot generated by <template v-if="..." #foo>
34 slots[slot.name] = slot.key
35 ? (...args: any[]) => {
36 const res = slot.fn(...args)
37 // attach branch key so each conditional branch is considered a
38 // different fragment
39 if (res) (res as any).key = slot.key
40 return res
41 }
42 : slot.fn
43 }
44 }
45 return slots
46}

Callers 3

legacyResolveScopedSlotsFunction · 0.90
setupFunction · 0.90

Calls

no outgoing calls

Tested by 1

setupFunction · 0.72