perf( runtime-core): use `apply` to avoid spreading. (#5985)

This commit is contained in:
zhangenming 2024-08-19 16:25:01 +08:00 committed by GitHub
parent 98b83e86d1
commit bb6babca8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View File

@ -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 {

View File

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