From eb8020a90cf415a2d061c2f5cf093f9ac3318ebf Mon Sep 17 00:00:00 2001 From: shirakaba <14055146+shirakaba@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:54:38 +0900 Subject: [PATCH] fix: apply -> call --- packages/core/data/dom-events/dom-event.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/data/dom-events/dom-event.ts b/packages/core/data/dom-events/dom-event.ts index 186b51a01..19b53f90d 100644 --- a/packages/core/data/dom-events/dom-event.ts +++ b/packages/core/data/dom-events/dom-event.ts @@ -418,7 +418,11 @@ export class DOMEvent implements Event { // Consistent with the original implementation, we only apply // context to the function if thisArg is truthy. - const returnValue = callback.apply(thisArg || undefined, [data]); + // + // We prefer Function.call() over Function.apply() as it avoids + // having to allocate an array just to hold the args (saves 30 + // nanoseconds per dispatchTo() call). + const returnValue = callback.call(thisArg || undefined, data); // This ensures that errors thrown inside asynchronous functions do // not get swallowed.