From cdc143d3489235375d6bb4e015025ed82e99bad4 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sun, 13 Oct 2019 07:34:22 +0800 Subject: [PATCH] refactor(runtime-core): use `Array.from` instead of loop over `iterable` (#250) --- packages/runtime-core/src/helpers/renderList.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/runtime-core/src/helpers/renderList.ts b/packages/runtime-core/src/helpers/renderList.ts index ea0b6f89..43841f31 100644 --- a/packages/runtime-core/src/helpers/renderList.ts +++ b/packages/runtime-core/src/helpers/renderList.ts @@ -16,13 +16,10 @@ export function renderList( } } else if (isObject(source)) { if (source[Symbol.iterator as any]) { - ret = [] - const iterator: Iterator = 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, + renderItem + ) } else { const keys = Object.keys(source) ret = new Array(keys.length)