From: zhangenming <282126346@qq.com> Date: Mon, 19 Aug 2024 08:25:01 +0000 (+0800) Subject: perf( runtime-core): use `apply` to avoid spreading. (#5985) X-Git-Tag: v3.5.0-beta.3~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb6babca8f206615d4e246457cd54d21bb3bc5a4;p=thirdparty%2Fvuejs%2Fcore.git perf( runtime-core): use `apply` to avoid spreading. (#5985) --- diff --git a/packages/runtime-core/src/compat/global.ts b/packages/runtime-core/src/compat/global.ts index 5356ce790d..edc57436a5 100644 --- a/packages/runtime-core/src/compat/global.ts +++ b/packages/runtime-core/src/compat/global.ts @@ -622,11 +622,9 @@ function defineReactive(obj: any, key: string, val: any) { if (isObject(val) && !isReactive(val) && !patched.has(val)) { const reactiveVal = reactive(val) if (isArray(val)) { - methodsToPatch.forEach(m => { - // @ts-expect-error + methodsToPatch.forEach((m: any) => { val[m] = (...args: any[]) => { - // @ts-expect-error - Array.prototype[m].call(reactiveVal, ...args) + Array.prototype[m].apply(reactiveVal, args) } }) } else { diff --git a/packages/runtime-core/src/compat/instanceEventEmitter.ts b/packages/runtime-core/src/compat/instanceEventEmitter.ts index 630df1cfe7..cdf2d79886 100644 --- a/packages/runtime-core/src/compat/instanceEventEmitter.ts +++ b/packages/runtime-core/src/compat/instanceEventEmitter.ts @@ -53,7 +53,7 @@ export function once( ): ComponentPublicInstance | null { const wrapped = (...args: any[]) => { off(instance, event, wrapped) - fn.call(instance.proxy, ...args) + fn.apply(instance.proxy, args) } wrapped.fn = fn on(instance, event, wrapped)