refactor(runtime-core): use Array.from instead of loop over iterable (#250)

This commit is contained in:
fisker Cheung 2019-10-13 07:34:22 +08:00 committed by Evan You
parent 96681942c1
commit cdc143d348

View File

@ -16,13 +16,10 @@ export function renderList(
}
} else if (isObject(source)) {
if (source[Symbol.iterator as any]) {
ret = []
const iterator: Iterator<any> = source[Symbol.iterator as any]()
let result = iterator.next()
while (!result.done) {
ret.push(renderItem(result.value, ret.length))
result = iterator.next()
}
ret = Array.from(
source as Iterable<any>,
renderItem
)
} else {
const keys = Object.keys(source)
ret = new Array(keys.length)