fix(shared): ensure invokeArrayFns handles undefined arguments (#10869)
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com> Close #10863
This commit is contained in:
parent
6a8d548506
commit
9b40d0f25d
|
@ -40,6 +40,8 @@ describe('api: lifecycle hooks', () => {
|
||||||
}
|
}
|
||||||
render(h(Comp), root)
|
render(h(Comp), root)
|
||||||
expect(fn).toHaveBeenCalledTimes(1)
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
|
// #10863
|
||||||
|
expect(fn).toHaveBeenCalledWith()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('onMounted', () => {
|
it('onMounted', () => {
|
||||||
|
|
|
@ -133,9 +133,9 @@ export const toHandlerKey = cacheStringFunction(<T extends string>(str: T) => {
|
||||||
export const hasChanged = (value: any, oldValue: any): boolean =>
|
export const hasChanged = (value: any, oldValue: any): boolean =>
|
||||||
!Object.is(value, oldValue)
|
!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++) {
|
for (let i = 0; i < fns.length; i++) {
|
||||||
fns[i](arg)
|
fns[i](...arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue