From 5de493d0740835e0d7dbd0e90bcc679df835547f Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 17 Jun 2012 00:15:12 -0700 Subject: Use the browser's built-in bind() instead of our proxy() --- background_scripts/completion.coffee | 4 ++-- lib/utils.coffee | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 5d0f939a..b9069dce 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -174,7 +174,7 @@ class DomainCompleter if domain previousEntry = @domains[domain] @domains[domain] = entry if !previousEntry || (previousEntry.lastVisitTime < entry.lastVisitTime) - chrome.history.onVisited.addListener(@onPageVisited.proxy(this)) + chrome.history.onVisited.addListener(@onPageVisited.bind(this)) onComplete() onPageVisited: (newPage) -> @@ -320,7 +320,7 @@ HistoryCache = chrome.history.search { text: "", maxResults: @size, startTime: 0 }, (history) => history.sort @compareHistoryByUrl @history = history - chrome.history.onVisited.addListener(@onPageVisited.proxy(this)) + chrome.history.onVisited.addListener(@onPageVisited.bind(this)) callback(@history) for callback in @callbacks @callbacks = null diff --git a/lib/utils.coffee b/lib/utils.coffee index c83a6cf8..6a846ae0 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -103,11 +103,6 @@ Utils = string = string.trim() if (Utils.isUrl(string)) then Utils.createFullUrl(string) else Utils.createSearchUrl(string) -# Execute a function with the given value for "this". Equivalent to jQuery.proxy(). */ -Function.prototype.proxy = (self) -> - fn = this - return -> fn.apply(self, arguments) - # This creates a new function out of an existing function, where the new function takes fewer arguments. # This allows us to pass around functions instead of functions + a partial list of arguments. Function.prototype.curry = -> -- cgit v1.2.3