From 218e786fcecde246993edccc27620c02466a7b0f Mon Sep 17 00:00:00 2001 From: daiwei Date: Thu, 26 Dec 2024 09:13:04 +0800 Subject: [PATCH 1/3] fix(runtime-vapor): properly normalize emits options if emits is an array --- packages/runtime-vapor/src/componentEmits.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-vapor/src/componentEmits.ts b/packages/runtime-vapor/src/componentEmits.ts index f26c6813505..60007037ef3 100644 --- a/packages/runtime-vapor/src/componentEmits.ts +++ b/packages/runtime-vapor/src/componentEmits.ts @@ -18,7 +18,7 @@ export function normalizeEmitsOptions( let normalized: ObjectEmitsOptions if (isArray(raw)) { normalized = {} - for (const key in raw) normalized[key] = null + for (const key of raw) normalized[key] = null } else { normalized = raw } From 3fc508382873bbd0df1c2385f9178d3f571a00a0 Mon Sep 17 00:00:00 2001 From: daiwei Date: Thu, 26 Dec 2024 09:24:56 +0800 Subject: [PATCH 2/3] test: add case for validator warning --- .../runtime-vapor/__tests__/componentEmits.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/runtime-vapor/__tests__/componentEmits.spec.ts b/packages/runtime-vapor/__tests__/componentEmits.spec.ts index 7c3bfe69ed4..74fc38a1b09 100644 --- a/packages/runtime-vapor/__tests__/componentEmits.spec.ts +++ b/packages/runtime-vapor/__tests__/componentEmits.spec.ts @@ -195,8 +195,17 @@ describe('component: emit', () => { ).not.toHaveBeenWarned() }) - test.todo('validator warning', () => { - // TODO: warning validator + test('validator warning', () => { + define({ + emits: { + foo: (arg: number) => arg > 0, + }, + setup(_, { emit }) { + emit('foo', -1) + return [] + }, + }).render() + expect(`event validation failed for event "foo"`).toHaveBeenWarned() }) test('.once', () => { From 50c9c27b2fa72994fbe23d3339021e969f5e19da Mon Sep 17 00:00:00 2001 From: daiwei Date: Thu, 26 Dec 2024 09:26:40 +0800 Subject: [PATCH 3/3] test: remove todos since not support mixins in vapor mode --- packages/runtime-vapor/__tests__/componentEmits.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/runtime-vapor/__tests__/componentEmits.spec.ts b/packages/runtime-vapor/__tests__/componentEmits.spec.ts index 74fc38a1b09..8c8a56085ba 100644 --- a/packages/runtime-vapor/__tests__/componentEmits.spec.ts +++ b/packages/runtime-vapor/__tests__/componentEmits.spec.ts @@ -424,8 +424,4 @@ describe('component: emit', () => { await nextTick() expect(fn).not.toHaveBeenCalled() }) - - // NOTE: not supported mixins - // test.todo('merge string array emits', async () => {}) - // test.todo('merge object emits', async () => {}) })