From 764b060cbd2ff26a5570c0047d7f2b1941aa763b Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 12 Jan 2016 12:01:45 -0500 Subject: [PATCH] Allow event functions to be defined as functions AND strings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current behavior (in `master`) is to define the handling functions for events as strings. Default for `onSort` for example is `handleSort`. Commit 8cef762d11dbabb27e489727bcc8fd5dfe8d844d changed this behavior forcing handling functions to be defined as functions in the options. This breaks all existing code, resulting in a no-op even with the default options (which still define the default handlers as strings). This commit restores previous behavior AND allows you to define your handlers as functions directly, if you’re so inclined. --- react-sortable-mixin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react-sortable-mixin.js b/react-sortable-mixin.js index 70ca0d0..165c269 100644 --- a/react-sortable-mixin.js +++ b/react-sortable-mixin.js @@ -87,6 +87,9 @@ emitEvent = function (/** string */type, /** Event */evt) { var method = options[type]; + if (method && typeof method === "string") { + method = this[method]; + } method && typeof method === "function" && method.call(this, evt, this._sortableInstance); }.bind(this);