Skip to content

Commit 7dc389b

Browse files
jh-leonglynxlangya
authored andcommitted
fix(shared): ensure invokeArrayFns handles undefined arguments (vuejs#10869)
Co-authored-by: Haoqun Jiang <[email protected]> Close vuejs#10863
1 parent 748b6dc commit 7dc389b

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
@@ -134,9 +134,9 @@ export const toHandlerKey = cacheStringFunction(<T extends string>(str: T) => {
134134
export const hasChanged = (value: any, oldValue: any): boolean =>
135135
!Object.is(value, oldValue)
136136

137-
export const invokeArrayFns = (fns: Function[], arg?: any) => {
137+
export const invokeArrayFns = (fns: Function[], ...arg: any[]) => {
138138
for (let i = 0; i < fns.length; i++) {
139-
fns[i](arg)
139+
fns[i](...arg)
140140
}
141141
}
142142

0 commit comments

Comments
 (0)