Skip to content

Commit

Permalink
fix(shared): ensure invokeArrayFns handles undefined arguments (#10869)
Browse files Browse the repository at this point in the history
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>

Close #10863
  • Loading branch information
jh-leong authored May 20, 2024
1 parent 6a8d548 commit 9b40d0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/runtime-core/__tests__/apiLifecycle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('api: lifecycle hooks', () => {
}
render(h(Comp), root)
expect(fn).toHaveBeenCalledTimes(1)
// #10863
expect(fn).toHaveBeenCalledWith()
})

it('onMounted', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 9b40d0f

Please sign in to comment.