From 626b665ef61534bf4a69bebb0cac4466fdd1202e Mon Sep 17 00:00:00 2001 From: Scott Nelson Date: Sun, 1 Sep 2013 23:30:40 -0400 Subject: [PATCH] Support binding directly to function --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d3ed75b..e0035d9 100644 --- a/index.js +++ b/index.js @@ -74,10 +74,12 @@ Events.prototype.bind = function(event, method){ var method = method || 'on' + name; var args = [].slice.call(arguments, 2); + if ('function' != typeof method) method = obj[method]; + // callback function cb(){ var a = [].slice.call(arguments).concat(args); - obj[method].apply(obj, a); + method.apply(obj, a); } // bind