diff options
| author | Phil Crosby | 2012-05-04 23:09:04 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-05-05 18:32:13 -0700 |
| commit | 238d7c86f4518331cf7563d6baf622401e07a59c (patch) | |
| tree | f69a9e1343165f8203c3a7eb885d49714c1fd05b /lib | |
| parent | 55d13097c9ff8f6301a4bf64b42740ae5edcf71c (diff) | |
| download | vimium-238d7c86f4518331cf7563d6baf622401e07a59c.tar.bz2 | |
use proxy instead of self
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); }; +}; /* |
