Skip to content

Commit

Permalink
fix(shared): ensure invokeArrayFns handles undefined arguments (vuejs…
Browse files Browse the repository at this point in the history
…#10869)

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

Close vuejs#10863
  • Loading branch information
jh-leong authored and lynxlangya committed May 30, 2024
1 parent 748b6dc commit 7dc389b
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 @@ -134,9 +134,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 7dc389b

Please sign in to comment.