From 9b40d0f25da868a83b0d6bf99dbbdb3ca68bb700 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 20 May 2024 19:28:22 +0800 Subject: [PATCH] fix(shared): ensure invokeArrayFns handles undefined arguments (#10869) Co-authored-by: Haoqun Jiang Close #10863 --- packages/runtime-core/__tests__/apiLifecycle.spec.ts | 2 ++ packages/shared/src/general.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/__tests__/apiLifecycle.spec.ts b/packages/runtime-core/__tests__/apiLifecycle.spec.ts index 5da57ab32..43054800a 100644 --- a/packages/runtime-core/__tests__/apiLifecycle.spec.ts +++ b/packages/runtime-core/__tests__/apiLifecycle.spec.ts @@ -40,6 +40,8 @@ describe('api: lifecycle hooks', () => { } render(h(Comp), root) expect(fn).toHaveBeenCalledTimes(1) + // #10863 + expect(fn).toHaveBeenCalledWith() }) it('onMounted', () => { diff --git a/packages/shared/src/general.ts b/packages/shared/src/general.ts index fb884695d..d2add1255 100644 --- a/packages/shared/src/general.ts +++ b/packages/shared/src/general.ts @@ -133,9 +133,9 @@ export const toHandlerKey = cacheStringFunction((str: T) => { export const hasChanged = (value: any, oldValue: any): boolean => !Object.is(value, oldValue) -export const invokeArrayFns = (fns: Function[], arg?: any) => { +export const invokeArrayFns = (fns: Function[], ...arg: any[]) => { for (let i = 0; i < fns.length; i++) { - fns[i](arg) + fns[i](...arg) } }