فهرست منبع

fix(shared): ensure invokeArrayFns handles undefined arguments (#10869)

Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>

Close #10863
Tycho 1 سال پیش
والد
کامیت
9b40d0f25d
2فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 2 0
      packages/runtime-core/__tests__/apiLifecycle.spec.ts
  2. 2 2
      packages/shared/src/general.ts

+ 2 - 0
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', () => {

+ 2 - 2
packages/shared/src/general.ts

@@ -133,9 +133,9 @@ export const toHandlerKey = cacheStringFunction(<T extends string>(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)
   }
 }