From 41394317942e5151a3218511b772cbc955cc02e9 Mon Sep 17 00:00:00 2001 From: "K." Date: Thu, 25 Aug 2016 11:34:11 +0500 Subject: [PATCH] Optimization invoking handler with multiple arguments. --- modules/eventlisteners.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/eventlisteners.js b/modules/eventlisteners.js index f086a43..34ad98d 100644 --- a/modules/eventlisteners.js +++ b/modules/eventlisteners.js @@ -6,9 +6,14 @@ function invokeHandler(handler, vnode, event) { // call handler with arguments if (typeof handler[0] === "function") { // special case for single argument for performance - handler.length === 2 ? - handler[0].call(vnode, handler[1], event, vnode) : - handler[0].apply(vnode, handler.slice(1).concat(event, vnode)); + if (handler.length === 2) { + handler[0].call(vnode, handler[1], event, vnode); + } else { + var args = handler.slice(1); + args.push(event); + args.push(vnode); + handler[0].apply(vnode, args); + } } else { // call multiple handlers for (var i = 0; i < handler.length; i++) {