fix(shared): ensure invokeArrayFns handles undefined arguments (#10869)

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

Close #10863
This commit is contained in:
Tycho 2024-05-20 19:28:22 +08:00 committed by GitHub
parent 6a8d548506
commit 9b40d0f25d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -40,6 +40,8 @@ describe('api: lifecycle hooks', () => {
}
render(h(Comp), root)
expect(fn).toHaveBeenCalledTimes(1)
// #10863
expect(fn).toHaveBeenCalledWith()
})
it('onMounted', () => {

View File

@ -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)
}
}