diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/completion.js | 9 | ||||
| -rw-r--r-- | lib/utils.js | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/completion.js b/lib/completion.js index 7e4bcf57..14c2dbe4 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -50,8 +50,7 @@ var completion = (function() { }, filter: function(query, callback) { - var self = this; - var handler = function(results) { callback(self.processResults(query, results)); } + var handler = function(results) { callback(this.processResults(query, results)); }.proxy(this); // are the results ready? if (this.completions !== null) { @@ -61,9 +60,9 @@ var completion = (function() { // no: register the handler as a callback this.resultsReady = function(results) { handler(results); - self.resultsReady = self.fallbackReadyCallback; - self.resultsReady(results); - } + this.resultsReady = this.fallbackReadyCallback; + this.resultsReady(results); + }.proxy(this); } } }); diff --git a/lib/utils.js b/lib/utils.js index 3a355d7b..d6b7bb93 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -160,7 +160,10 @@ var utils = { }; /* Execute a function with the given value for "this". Equivalent to jQuery.proxy(). */ -Function.prototype.proxy = function(fn, self) { return function() { fn.apply(self, arguments); }; }; +Function.prototype.proxy = function(self) { + var fn = this; + return function() { return fn.apply(self, arguments); }; +}; /* |
