Skip to content

Commit 9b40d0f

Browse files
authoredMay 20, 2024··
fix(shared): ensure invokeArrayFns handles undefined arguments (#10869)
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com> Close #10863
1 parent 6a8d548 commit 9b40d0f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎packages/runtime-core/__tests__/apiLifecycle.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ describe('api: lifecycle hooks', () => {
4040
}
4141
render(h(Comp), root)
4242
expect(fn).toHaveBeenCalledTimes(1)
43+
// #10863
44+
expect(fn).toHaveBeenCalledWith()
4345
})
4446

4547
it('onMounted', () => {

‎packages/shared/src/general.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ export const toHandlerKey = cacheStringFunction(<T extends string>(str: T) => {
133133
export const hasChanged = (value: any, oldValue: any): boolean =>
134134
!Object.is(value, oldValue)
135135

136-
export const invokeArrayFns = (fns: Function[], arg?: any) => {
136+
export const invokeArrayFns = (fns: Function[], ...arg: any[]) => {
137137
for (let i = 0; i < fns.length; i++) {
138-
fns[i](arg)
138+
fns[i](...arg)
139139
}
140140
}
141141

0 commit comments

Comments
 (0)
Please sign in to comment.