8000 fix: apply -> call · NativeScript/NativeScript@eb8020a · GitHub
[go: up one dir, main page]

Skip to content

Commit eb8020a

Browse files
committed
fix: apply -> call
1 parent 08bc87b commit eb8020a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/core/data/dom-events/dom-event.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ export class DOMEvent implements Event {
418418

419419
// Consistent with the original implementation, we only apply
420420
// context to the function if thisArg is truthy.
421-
const returnValue = callback.apply(thisArg || undefined, [data]);
421+
//
422+
// We prefer Function.call() over Function.apply() as it avoids
423+
// having to allocate an array just to hold the args (saves 30
424+
// nanoseconds per dispatchTo() call).
425+
const returnValue = callback.call(thisArg || undefined, data);
422426

423427
// This ensures that errors thrown inside asynchronous functions do
424428
// not get swallowed.

0 commit comments

Comments
 (0)
0