]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(shared): ensure invokeArrayFns handles undefined arguments (#10869)
authorTycho <jh.leong@outlook.com>
Mon, 20 May 2024 11:28:22 +0000 (19:28 +0800)
committerGitHub <noreply@github.com>
Mon, 20 May 2024 11:28:22 +0000 (19:28 +0800)
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>
Close #10863

packages/runtime-core/__tests__/apiLifecycle.spec.ts
packages/shared/src/general.ts

index 5da57ab32bf9f35baa699f87c3f41c142ea6dd3f..43054800afe88314cf25021e19980f0966f471a6 100644 (file)
@@ -40,6 +40,8 @@ describe('api: lifecycle hooks', () => {
     }
     render(h(Comp), root)
     expect(fn).toHaveBeenCalledTimes(1)
+    // #10863
+    expect(fn).toHaveBeenCalledWith()
   })
 
   it('onMounted', () => {
index fb884695d336c6d91b590199956a91aeda918287..d2add125502106df3e34bd95755ec8ce336420b7 100644 (file)
@@ -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)
   }
 }