Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/common.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Addressed some more feedback Created Jan. 18, 2017, 11:44 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ext/background.js ('k') | include.preload.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/common.js
diff --git a/ext/common.js b/ext/common.js
index c75ced186d633fc3bf4183be4fb5d9dd6c5db666..445dc73ad58621eae3adf7a5170a687e093707bd 100644
--- a/ext/common.js
+++ b/ext/common.js
@@ -15,36 +15,36 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
+"use strict";
-(function()
{
- window.ext = {};
+ var ext = {};
- var EventTarget = ext._EventTarget = function()
+ let EventTarget = ext._EventTarget = function()
{
this._listeners = [];
};
EventTarget.prototype = {
- addListener: function(listener)
+ addListener(listener)
{
if (this._listeners.indexOf(listener) == -1)
this._listeners.push(listener);
},
- removeListener: function(listener)
+ removeListener(listener)
{
- var idx = this._listeners.indexOf(listener);
+ let idx = this._listeners.indexOf(listener);
if (idx != -1)
this._listeners.splice(idx, 1);
},
- _dispatch: function()
+ _dispatch()
{
- var results = [];
- var listeners = this._listeners.slice();
+ let results = [];
+ let listeners = this._listeners.slice();
- for (var i = 0; i < listeners.length; i++)
- results.push(listeners[i].apply(null, arguments));
+ for (let listener of listeners)
+ results.push(listener.apply(null, arguments));
return results;
}
};
-})();
+}
« no previous file with comments | « ext/background.js ('k') | include.preload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld