Skip to content

Commit

Permalink
perf( runtime-core): use apply to avoid spreading. (#5985)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangenming committed Aug 19, 2024
1 parent 98b83e8 commit bb6babc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/runtime-core/src/compat/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/compat/instanceEventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bb6babc

Please sign in to comment.