Skip to content

Commit

Permalink
fix(shared): ensure invokeArrayFns handles undefined arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-leong committed May 15, 2024
1 parent c0c9432 commit 3a5dd5a
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 3a5dd5a

Please sign in to comment.