fix: apply -> call

This commit is contained in:
shirakaba
2022-12-20 18:54:38 +09:00
parent 08bc87b059
commit eb8020a90c

View File

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