]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/main.jsm
Import r6948 from upstream hg supporting Firefox up to 24.*
[dactyl.git] / common / modules / main.jsm
index 41ef16cf570cfcf40a260d4abbb934bf158bcbe6..ae6926d003589188bc6c1e821076575c24428bb4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2009-2013 Kris Maglione <maglione.k@gmail.com>
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
@@ -65,14 +65,13 @@ var Modules = function Modules(window) {
      *
      * @returns {function} The constructor for the resulting module.
      */
-    function Module(name) {
-        let args = Array.slice(arguments);
+    function Module(name, ...args) {
 
         var base = ModuleBase;
-        if (callable(args[1]))
-            base = args.splice(1, 1)[0];
+        if (callable(args[0]))
+            base = args.shift();
 
-        let [prototype, classProperties, moduleInit] = args;
+        let [prototype, classProperties, moduleInit] = args;
         prototype._metaInit_ = function () {
             delete module.prototype._metaInit_;
             Class.replaceProperty(modules, module.className, this);
@@ -92,7 +91,6 @@ var Modules = function Modules(window) {
 
     const create = window.Object.create.bind(window.Object);
 
-
     const BASES = [BASE, "resource://dactyl-local-content/"];
 
     jsmodules = Cu.createObjectIn(window);
@@ -322,25 +320,24 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
     },
 
     scanModules: function scanModules() {
-        let self = this;
         let { Module, modules } = this.modules;
 
-        defineModule.modules.forEach(function defModule(mod) {
+        defineModule.modules.forEach((mod) => {
             let names = Set(Object.keys(mod.INIT));
             if ("init" in mod.INIT)
                 Set.add(names, "init");
 
-            keys(names).forEach(function (name) { self.deferInit(name, mod.INIT, mod); });
+            keys(names).forEach((name) => { this.deferInit(name, mod.INIT, mod); });
         });
 
-        Module.list.forEach(function frobModule(mod) {
+        Module.list.forEach((mod) => {
             if (!mod.frobbed) {
-                modules.__defineGetter__(mod.className, function () {
+                modules.__defineGetter__(mod.className, () => {
                     delete modules[mod.className];
-                    return self.loadModule(mod.className, null, Components.stack.caller);
+                    return this.loadModule(mod.className, null, Components.stack.caller);
                 });
                 Object.keys(mod.prototype.INIT)
-                      .forEach(function (name) { self.deferInit(name, mod.prototype.INIT, mod); });
+                      .forEach((name) => { this.deferInit(name, mod.prototype.INIT, mod); });
             }
             mod.frobbed = true;
         });
@@ -357,4 +354,4 @@ endModule();
 
 } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
 
-// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: