forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslot.js
More file actions
36 lines (32 loc) · 859 Bytes
/
slot.js
File metadata and controls
36 lines (32 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export function slot (vm, slotName, otherwise) {
return vm.$scopedSlots[slotName] !== void 0
? vm.$scopedSlots[slotName]()
: otherwise
}
export function uniqueSlot (vm, slotName, otherwise) {
return vm.$scopedSlots[slotName] !== void 0
? [].concat(vm.$scopedSlots[slotName]())
: otherwise
}
/**
* Source definitely exists,
* so it's merged with the possible slot
*/
export function mergeSlot (source, vm, slotName) {
return vm.$scopedSlots[slotName] !== void 0
? source.concat(vm.$scopedSlots[slotName]())
: source
}
/**
* Merge with possible slot,
* even if source might not exist
*/
export function mergeSlotSafely (source, vm, slotName) {
if (vm.$scopedSlots[slotName] === void 0) {
return source
}
const slot = vm.$scopedSlots[slotName]()
return source !== void 0
? source.concat(slot)
: slot
}