From 957179fc7fc719d29b6203b2caff66b8c26e229f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Feb 2018 08:47:49 -0500 Subject: [PATCH] use local `this` variable instead of .bind --- store.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/store.js b/store.js index 69234551135b..9f0661811b34 100644 --- a/store.js +++ b/store.js @@ -111,11 +111,14 @@ assign(Store.prototype, { onchange: function(callback) { this._changeHandlers.push(callback); + + var store = this; + return { cancel: function() { - var index = this._changeHandlers.indexOf(callback); - if (~index) this._changeHandlers.splice(index, 1); - }.bind(this) + var index = store._changeHandlers.indexOf(callback); + if (~index) store._changeHandlers.splice(index, 1); + } }; },