From 67099fe20299a51f9974f0e2f9ef19ca05efe92b Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 6 May 2022 16:49:15 +0800 Subject: [PATCH] fix(runtime-core): ensure consistent behavior between dev/prod on invalid v-for range close #5867 --- packages/runtime-core/__tests__/helpers/renderList.spec.ts | 4 +++- packages/runtime-core/src/helpers/renderList.ts | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/__tests__/helpers/renderList.spec.ts b/packages/runtime-core/__tests__/helpers/renderList.spec.ts index 06d2825df36..ae487b6be23 100644 --- a/packages/runtime-core/__tests__/helpers/renderList.spec.ts +++ b/packages/runtime-core/__tests__/helpers/renderList.spec.ts @@ -22,7 +22,9 @@ describe('renderList', () => { }) it('should warn when given a non-integer N', () => { - renderList(3.1, () => {}) + try { + renderList(3.1, () => {}) + } catch (e) {} expect( `The v-for range expect an integer value but got 3.1.` ).toHaveBeenWarned() diff --git a/packages/runtime-core/src/helpers/renderList.ts b/packages/runtime-core/src/helpers/renderList.ts index 9fbf967a8ca..1655d555fb3 100644 --- a/packages/runtime-core/src/helpers/renderList.ts +++ b/packages/runtime-core/src/helpers/renderList.ts @@ -67,7 +67,6 @@ export function renderList( } else if (typeof source === 'number') { if (__DEV__ && !Number.isInteger(source)) { warn(`The v-for range expect an integer value but got ${source}.`) - return [] } ret = new Array(source) for (let i = 0; i < source; i++) {