fix(runtime-core): renderList with default value when source is undefined (#498)
This commit is contained in:
parent
bb39910e8e
commit
d4f4c7c4d4
@ -41,4 +41,10 @@ describe('renderList', () => {
|
|||||||
renderList(iterable(), (item, index) => `node ${index}: ${item}`)
|
renderList(iterable(), (item, index) => `node ${index}: ${item}`)
|
||||||
).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
|
).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should return empty array when source is undefined', () => {
|
||||||
|
expect(
|
||||||
|
renderList(undefined, (item, index) => `node ${index}: ${item}`)
|
||||||
|
).toEqual([])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -31,6 +31,8 @@ export function renderList(
|
|||||||
ret[i] = renderItem(source[key], key, i)
|
ret[i] = renderItem(source[key], key, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ret = []
|
||||||
}
|
}
|
||||||
return ret!
|
return ret
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user