vue2/src/core/instance/render-helpers/resolve-scoped-slots.js

23 lines
590 B
JavaScript

/* @flow */
export function resolveScopedSlots (
fns: ScopedSlotsData, // see flow/vnode
hasDynamicKeys?: boolean,
res?: Object
): { [key: string]: Function, $stable: boolean } {
res = res || { $stable: !hasDynamicKeys }
for (let i = 0; i < fns.length; i++) {
const slot = fns[i]
if (Array.isArray(slot)) {
resolveScopedSlots(slot, hasDynamicKeys, res)
} else if (slot) {
// marker for reverse proxying v-slot without scope on this.$slots
if (slot.proxy) {
slot.fn.proxy = true
}
res[slot.key] = slot.fn
}
}
return res
}