fix(slots): fix conditional slot

fix #787
This commit is contained in:
Evan You 2020-02-26 21:43:27 -05:00
parent 5d952cc051
commit 3357ff438c

View File

@ -8,7 +8,10 @@ interface CompiledSlotDescriptor {
export function createSlots(
slots: Record<string, Slot>,
dynamicSlots: (CompiledSlotDescriptor | CompiledSlotDescriptor[])[]
dynamicSlots: (
| CompiledSlotDescriptor
| CompiledSlotDescriptor[]
| undefined)[]
): Record<string, Slot> {
for (let i = 0; i < dynamicSlots.length; i++) {
const slot = dynamicSlots[i]
@ -17,7 +20,7 @@ export function createSlots(
for (let j = 0; j < slot.length; j++) {
slots[slot[j].name] = slot[j].fn
}
} else {
} else if (slot) {
// conditional single slot generated by <template v-if="..." #foo>
slots[slot.name] = slot.fn
}