diff --git a/common/content/commandline.js b/common/content/commandline.js index 735423f6..7d0c605b 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -167,11 +167,11 @@ var CommandWidgets = Class("CommandWidgets", { function get(prefix, map, id) (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id)); - this.active.__defineGetter__(obj.name, function () self.activeGroup[obj.name][obj.name]); - this.activeGroup.__defineGetter__(obj.name, function () self.getGroup(obj.name)); + this.active.__defineGetter__(obj.name, () => this.activeGroup[obj.name][obj.name]); + this.activeGroup.__defineGetter__(obj.name, () => this.getGroup(obj.name)); - memoize(this.statusbar, obj.name, function () get("dactyl-statusline-field-", statusline.widgets, (obj.id || obj.name))); - memoize(this.commandbar, obj.name, function () get("dactyl-", {}, (obj.id || obj.name))); + memoize(this.statusbar, obj.name, () => get("dactyl-statusline-field-", statusline.widgets, (obj.id || obj.name))); + memoize(this.commandbar, obj.name, () => get("dactyl-", {}, (obj.id || obj.name))); if (!(obj.noValue || obj.getValue)) { Object.defineProperty(this, obj.name, Modes.boundProperty({ @@ -504,8 +504,6 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, { */ var CommandLine = Module("commandline", { init: function init() { - const self = this; - this._callbacks = {}; memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true })); @@ -777,13 +775,12 @@ var CommandLine = Module("commandline", { highlightGroup = highlightGroup || this.HL_NORMAL; - let self = this; - function appendToMessages(data) { + let appendToMessages = (data) => { let message = isObject(data) && !DOM.isJSONXML(data) ? data : { message: data }; // Make sure the memoized message property is an instance property. message.message; - self._messageHistory.add(update({ highlight: highlightGroup }, message)); + this._messageHistory.add(update({ highlight: highlightGroup }, message)); return message.message; } @@ -802,7 +799,7 @@ var CommandLine = Module("commandline", { if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isinstance(data, [_, "String"])) && !(flags & this.FORCE_SINGLELINE)) action = mow.closure.echo; - let checkSingleLine = function () action == self._echoLine; + let checkSingleLine = () => action == this._echoLine; if (forceSingle) { this._lastEcho = null; diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e96b39e7..a0bcda8e 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. diff --git a/common/content/key-processors.js b/common/content/key-processors.js index 285b345f..08cc401a 100644 --- a/common/content/key-processors.js +++ b/common/content/key-processors.js @@ -250,18 +250,17 @@ var KeyProcessor = Class("KeyProcessor", { }, execute: function execute(map, args) - let (self = this) - function execute() { - if (self.preExecute) - self.preExecute.apply(self, args); + () => { + if (this.preExecute) + this.preExecute.apply(this, args); - args.self = self.main.params.mappingSelf || self.main.mappingSelf || map; - let res = map.execute.call(map, args); + args.self = this.main.params.mappingSelf || this.main.mappingSelf || map; + let res = map.execute.call(map, args); - if (self.postExecute) - self.postExecute.apply(self, args); - return res; - }, + if (this.postExecute) + this.postExecute.apply(this, args); + return res; + }, onKeyPress: function onKeyPress(event) { if (event.skipmap) diff --git a/common/content/mappings.js b/common/content/mappings.js index caa1a39a..68bba94c 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -123,8 +123,7 @@ var Map = Class("Map", { contexts.context, args); - let self = this; - function repeat() self.action(args) + let repeat = () => this.action(args); if (this.names[0] != ".") // FIXME: Kludge. mappings.repeat = repeat; diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index dbba054c..bfe53a66 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -211,9 +211,8 @@ var Addon = Class("Addon", { }, update: function callee() { - let self = this; - function update(key, xml) { - let node = self.nodes[key]; + let update = (key, xml) => { + let node = this.nodes[key]; while (node.firstChild) node.removeChild(node.firstChild); diff --git a/common/modules/base.jsm b/common/modules/base.jsm index ab6421d9..cdeb598a 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2012 Kris Maglione +// Copyright (c) 2009-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -953,14 +953,13 @@ Class.prototype = { * @returns {nsITimer} The timer which backs this timeout. */ timeout: function timeout(callback, timeout) { - const self = this; - function timeout_notify(timer) { - if (self.stale || + let timeout_notify = (timer) => { + if (this.stale || util.rehashing && !isinstance(Cu.getGlobalForObject(callback), ["BackstagePass"])) return; - self.timeouts.splice(self.timeouts.indexOf(timer), 1); - util.trapErrors(callback, self); - } + this.timeouts.splice(this.timeouts.indexOf(timer), 1); + util.trapErrors(callback, this); + }; let timer = services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT); this.timeouts.push(timer); return timer; @@ -973,12 +972,11 @@ Class.prototype = { * localized properties. */ update: function update() { - let self = this; // XXX: Duplication. for (let i = 0; i < arguments.length; i++) { let src = arguments[i]; - Object.getOwnPropertyNames(src || {}).forEach(function (k) { + Object.getOwnPropertyNames(src || {}).forEach((k) => { let desc = Object.getOwnPropertyDescriptor(src, k); if (desc.value instanceof Class.Property) desc = desc.value.init(k, this) || desc.value; @@ -986,12 +984,16 @@ Class.prototype = { if (typeof desc.value === "function") { let func = desc.value.wrapped || desc.value; if (!func.superapply) { - func.__defineGetter__("super", function () Object.getPrototypeOf(self)[k]); - func.superapply = function superapply(self, args) - let (meth = Object.getPrototypeOf(self)[k]) - meth && meth.apply(self, args); - func.supercall = function supercall(self) - func.superapply(self, Array.slice(arguments, 1)); + func.__defineGetter__("super", () => Object.getPrototypeOf(this)[k]); + + func.superapply = function superapply(self, args) { + let meth = Object.getPrototypeOf(self)[k]; + return meth && meth.apply(self, args); + }; + + func.supercall = function supercall(self) { + return func.superapply(self, Array.slice(arguments, 1)); + } } } diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index 7df2544f..534dee73 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -995,8 +995,6 @@ var Buffer = Module("Buffer", { showPageInfo: function showPageInfo(verbose, sections) { let { commandline, dactyl, options } = this.modules; - let self = this; - // Ctrl-g single line output if (!verbose) { let file = this.win.location.pathname.split("/").pop() || _("buffer.noName"); @@ -1004,7 +1002,7 @@ var Buffer = Module("Buffer", { let info = template.map( (sections || options["pageinfo"]) - .map(function (opt) Buffer.pageInfo[opt].action.call(self)), + .map((opt) => Buffer.pageInfo[opt].action.call(this)), function (res) res && iter(res).join(", ") || undefined, ", ").join(""); @@ -1016,9 +1014,9 @@ var Buffer = Module("Buffer", { return; } - let list = template.map(sections || options["pageinfo"], function (option) { + let list = template.map(sections || options["pageinfo"], (option) => { let { action, title } = Buffer.pageInfo[option]; - return template.table(title, action.call(self, true)); + return template.table(title, action.call(this, true)); }, ["br"]); commandline.commandOutput(list); @@ -1254,14 +1252,13 @@ var Buffer = Module("Buffer", { * Updates the zoom level of this buffer from a content preference. */ updateZoom: util.wrapCallback(function updateZoom() { - let self = this; let uri = this.uri; if (prefs.get("browser.zoom.siteSpecific")) { - this.getPref("dactyl.content.full-zoom", function (val) { - if (val != null && uri.equals(self.uri) && val != prefs.get("browser.zoom.full")) - [self.contentViewer.textZoom, self.contentViewer.fullZoom] = - [self.contentViewer.fullZoom, self.contentViewer.textZoom]; + this.getPref("dactyl.content.full-zoom", (val) => { + if (val != null && uri.equals(this.uri) && val != prefs.get("browser.zoom.full")) + [this.contentViewer.textZoom, this.contentViewer.fullZoom] = + [this.contentViewer.fullZoom, this.contentViewer.textZoom]; }); } }), diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 63d3c6a3..92a5b47b 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -583,8 +583,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { this.remove(name); } - let self = this; - let closure = function () self._map[name]; + let closure = () => this._map[name]; memoize(this._map, name, function () commands.Command(specs, description, action, extra)); if (!extra.hidden) diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index 869a7c00..d3967880 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -135,10 +135,10 @@ var CompletionContext = Class("CompletionContext", { * {@link #filters} array. */ this.filterFunc = function filterFunc(items) { - let self = this; - return this.filters. - reduce(function r(res, filter) res.filter(function f(item) filter.call(self, item)), - items); + return this.filters + .reduce((res, filter) + => res.filter((item) => filter.call(this, item)), + items); }; /** * @property {Array} An array of predicates on which to filter the @@ -674,7 +674,6 @@ var CompletionContext = Class("CompletionContext", { }, getRows: function getRows(start, end, doc) { - let self = this; let items = this.items; let cache = this.cache.rows; let step = start > end ? -1 : 1; @@ -733,12 +732,10 @@ var CompletionContext = Class("CompletionContext", { }, split: function split(name, obj, fn) { - const self = this; - let context = this.fork(name); - function alias(prop) { - context.__defineGetter__(prop, function get_() self[prop]); - context.__defineSetter__(prop, function set_(val) self[prop] = val); + let alias = (prop) => { + context.__defineGetter__(prop, () => this[prop]); + context.__defineSetter__(prop, (val) => this[prop] = val); } alias("_cache"); alias("_completions"); @@ -821,7 +818,6 @@ var CompletionContext = Class("CompletionContext", { * context. */ reset: function reset() { - let self = this; if (this.parent) throw Error(); @@ -842,7 +838,7 @@ var CompletionContext = Class("CompletionContext", { this.value = this._value; this._caret = this.value.length; } - //for (let key in (k for ([k, v] in Iterator(self.contexts)) if (v.offset > this.caret))) + //for (let key in (k for ([k, v] in Iterator(this.contexts)) if (v.offset > this.caret))) // delete this.contexts[key]; for each (let context in this.contexts) { context.hasItems = false; diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index b20616ab..b75d32c4 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -19,8 +19,6 @@ var Const = function Const(val) Class.Property({ enumerable: true, value: val }) var Group = Class("Group", { init: function init(name, description, filter, persist) { - const self = this; - this.name = name; this.description = description; this.filter = filter || this.constructor.defaultFilter; @@ -171,13 +169,12 @@ var Contexts = Module("contexts", { Hives: Class("Hives", Class.Property, { init: function init(name, constructor) { const { contexts } = modules; - const self = this; if (this.Hive) return { enumerable: true, - get: function () array(contexts.groups[self.name]) + get: () => array(contexts.groups[this.name]) }; this.Hive = constructor; diff --git a/common/modules/downloads.jsm b/common/modules/downloads.jsm index 5d718a27..26ac1ccd 100644 --- a/common/modules/downloads.jsm +++ b/common/modules/downloads.jsm @@ -23,21 +23,20 @@ var states = iter([v, k.slice(prefix.length).toLowerCase()] var Download = Class("Download", { init: function init(id, list) { - let self = this; this.download = services.downloadManager.getDownload(id); this.list = list; this.nodes = { - commandTarget: self + commandTarget: this }; DOM.fromJSON( ["tr", { highlight: "Download", key: "row" }, ["td", { highlight: "DownloadTitle" }, ["span", { highlight: "Link" }, - ["a", { key: "launch", href: self.target.spec, path: self.targetFile.path }, - self.displayName], + ["a", { key: "launch", href: this.target.spec, path: this.targetFile.path }, + this.displayName], ["span", { highlight: "LinkInfo" }, - self.targetFile.path]]], + this.targetFile.path]]], ["td", { highlight: "DownloadState", key: "state" }], ["td", { highlight: "DownloadButtons Buttons" }, ["a", { highlight: "Button", href: "javascript:0", key: "pause" }, _("download.action.Pause")], @@ -54,19 +53,19 @@ var Download = Class("Download", { ["td", { highlight: "DownloadSpeed", key: "speed" }], ["td", { highlight: "DownloadTime", key: "time" }], ["td", {}, - ["a", { highlight: "DownloadSource", key: "source", href: self.source.spec }, - self.source.spec]]], + ["a", { highlight: "DownloadSource", key: "source", href: this.source.spec }, + this.source.spec]]], this.list.document, this.nodes); - this.nodes.launch.addEventListener("click", function (event) { + this.nodes.launch.addEventListener("click", (event) => { if (event.button == 0) { event.preventDefault(); - self.command("launch"); + this.command("launch"); } }, false); - self.updateStatus(); - return self; + this.updateStatus(); + return this; }, get status() states[this.state], @@ -102,7 +101,6 @@ var Download = Class("Download", { this.updateStatus(); }, launch: function launch() { - let self = this; // Behavior mimics that of the builtin Download Manager. function action() { try { @@ -119,13 +117,13 @@ var Download = Class("Download", { let file = io.File(this.targetFile); if (file.isExecutable() && prefs.get("browser.download.manager.alertOnEXEOpen", true)) this.list.modules.commandline.input(_("download.prompt.launchExecutable") + " ", - function (resp) { + (resp) => { if (/^a(lways)$/i.test(resp)) { prefs.set("browser.download.manager.alertOnEXEOpen", false); resp = "yes"; } if (/^y(es)?$/i.test(resp)) - action.call(self); + action.call(this); }); else action.call(this); diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index 7c15945d..fca93478 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -218,11 +218,12 @@ var Highlights = Module("Highlight", { * @param {string} class */ selector: function selector(class_) - let (self = this) - class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g, - function (m, n1, hl) n1 + - (self.highlight[hl] && self.highlight[hl].class != class_ - ? self.highlight[hl].selector : "[dactyl|highlight~=" + hl + "]")), + class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g, + (m, n1, hl) => { + if (this.highlight[hl] && this.highlight[hl].class != class_) + return n1 + this.highlight[hl].selector; + return n1 + "[dactyl|highlight~=" + hl + "]"; + }), groupRegexp: util.regexp(literal(/* ^ diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index 28c17612..06e4aa55 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -765,13 +765,12 @@ var JavaScript = Module("javascript", { init: function init(context) { init.supercall(this); - let self = this; let sandbox = true || isinstance(context, ["Sandbox"]); this.context = modules.newContext(context, !sandbox, "Dactyl REPL Context"); this.js = modules.JavaScript(); this.js.replContext = this.context; - this.js.newContext = function newContext() modules.newContext(self.context, !sandbox, "Dactyl REPL Temp Context"); + this.js.newContext = () => modules.newContext(this.context, !sandbox, "Dactyl REPL Temp Context"); this.js.globals = [ [this.context, /*L*/"REPL Variables"], diff --git a/common/modules/main.jsm b/common/modules/main.jsm index 2ad1e36c..555d2947 100644 --- a/common/modules/main.jsm +++ b/common/modules/main.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2012 Kris Maglione +// Copyright (c) 2009-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -321,25 +321,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; }); diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm index 0e752928..238be527 100644 --- a/common/modules/messages.jsm +++ b/common/modules/messages.jsm @@ -147,7 +147,6 @@ var Messages = Module("messages", { obj[_prop] = this.default; return { get: function get() { - let self = this; let value = this[_prop]; function getter(key, default_) function getter() messages.get([name, key].join("."), default_); diff --git a/common/modules/options.jsm b/common/modules/options.jsm index 5b644f5f..ac5ceb98 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2013 by Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -908,8 +908,6 @@ var Options = Module("options", { * @optional */ add: function add(names, description, type, defaultValue, extraInfo) { - const self = this; - if (!util.isDactyl(Components.stack.caller)) deprecated.warn(add, "options.add", "group.options.add"); @@ -927,7 +925,7 @@ var Options = Module("options", { this.remove(name); } - let closure = function () self._optionMap[name]; + let closure = () => this._optionMap[name]; memoize(this._optionMap, name, function () Option.types[type](modules, names, description, defaultValue, extraInfo)); for (let alias in values(names.slice(1))) diff --git a/common/modules/services.jsm b/common/modules/services.jsm index b67e8dad..377cd13e 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -139,7 +139,7 @@ var Services = Module("Services", { if (service.quiet === false) throw e.stack ? e : Error(e); - if (typeof util !== "undefined") + if (typeof util !== "undefined" && util != null) util.reportError(e); else dump("dactyl: Service creation failed for '" + service.class + "': " + e + "\n" + (e.stack || Error(e).stack)); @@ -176,13 +176,12 @@ var Services = Module("Services", { * class. */ addClass: function addClass(name, class_, ifaces, init, quiet) { - const self = this; this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []), method: "createInstance", init: init, quiet: quiet }; if (init) memoize(this.services[name], "callable", function () callable(XPCOMShim(this.interfaces)[this.init])); - this[name] = function Create() self._create(name, arguments); + this[name] = (function Create() this._create(name, arguments)).bind(this); update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))])); return this[name]; }, diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index b93f6d41..f37524d8 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -241,7 +241,6 @@ var Storage = Module("Storage", { }, newObject: function newObject(key, constructor, params) { - let self = this; if (params == null || !isObject(params)) throw Error("Invalid argument type"); @@ -261,10 +260,10 @@ var Storage = Module("Storage", { if (key in this && !reload) throw Error("Cannot add storage key with that name."); - let load = function () self._loadData(key, params.store, params.type || myObject); + let load = () => this._loadData(key, params.store, params.type || myObject); this.keys[key] = new constructor(key, params.store, load, params); - this.keys[key].timer = new Timer(1000, 10000, function () self.save(key)); + this.keys[key].timer = new Timer(1000, 10000, () => this.save(key)); this.__defineGetter__(key, function () this.keys[key]); } return this.keys[key]; diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index 6de607a2..ffa4c696 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -203,7 +203,6 @@ var Hive = Class("Hive", { * @param {number} index */ remove: function remove(name, filter, css, index) { - let self = this; if (arguments.length == 1) { var matches = [name]; name = null; @@ -211,7 +210,7 @@ var Hive = Class("Hive", { if (filter && filter.indexOf(",") > -1) return filter.split(",").reduce( - function (n, f) n + self.removeSheet(name, f, index), 0); + (n, f) => n + this.removeSheet(name, f, index), 0); if (filter == undefined) filter = ""; diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 5ee5cbbe..b9f5fda9 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -456,26 +456,24 @@ var Template = Module("Template", { }, tabular: function tabular(headings, style, iter) { - let self = this; // TODO: This might be mind-bogglingly slow. We'll see. return ["table", {}, ["tr", { highlight: "Title", align: "left" }, this.map(headings, function (h) ["th", {}, h])], - this.map(iter, function (row) + this.map(iter, (row) => ["tr", {}, - self.map(Iterator(row), function ([i, d]) + this.map(Iterator(row), function ([i, d]) ["td", { style: style[i] || "" }, d])])]; }, usage: function usage(iter, format) { - let self = this; format = format || {}; - let desc = format.description || function (item) self.linkifyHelp(item.description); - let help = format.help || function (item) item.name; - function sourceLink(frame) { - let source = self.sourceLink(frame); + let desc = format.description || (item => this.linkifyHelp(item.description)); + let help = format.help || (item => item.name); + let sourceLink = (frame) => { + let source = this.sourceLink(frame); source[1]["dactyl:hint"] = source[2]; return source; } @@ -483,25 +481,25 @@ var Template = Module("Template", { format.headings ? ["thead", { highlight: "UsageHead" }, ["tr", { highlight: "Title", align: "left" }, - this.map(format.headings, function (h) ["th", {}, h])]] : + this.map(format.headings, (h) => ["th", {}, h])]] : [], format.columns ? ["colgroup", {}, - this.map(format.columns, function (c) ["col", { style: c }])] : + this.map(format.columns, (c) => ["col", { style: c }])] : [], ["tbody", { highlight: "UsageBody" }, - this.map(iter, function (item) + this.map(iter, (item) => // Urgh. let (name = item.name || item.names[0], frame = item.definedAt) ["tr", { highlight: "UsageItem" }, ["td", { style: "padding-right: 2em;" }, ["span", { highlight: "Usage Link" }, !frame ? name : - [self.helpLink(help(item), name, "Title"), + [this.helpLink(help(item), name, "Title"), ["span", { highlight: "LinkInfo" }, _("io.definedAt"), " ", sourceLink(frame)]]]], - item.columns ? self.map(item.columns, function (c) ["td", {}, c]) : [], + item.columns ? this.map(item.columns, (c) => ["td", {}, c]) : [], ["td", {}, desc(item)]])]]; } }); diff --git a/common/tests/functional/dactyl.jsm b/common/tests/functional/dactyl.jsm index 5f7bda5a..a9555e21 100644 --- a/common/tests/functional/dactyl.jsm +++ b/common/tests/functional/dactyl.jsm @@ -40,7 +40,6 @@ function assertMessage(funcName, want, got, message) { * @param {MozMillController} controller The browser's MozMill controller. */ function Controller(controller) { - var self = this; this.controller = controller; /** @@ -51,13 +50,13 @@ function Controller(controller) { this.errorCount = 0; - this._countBeep = function countBeep() { - self.beepCount++; + this._countBeep = () => { + this.beepCount++; } this.errors = []; - this._countError = function countError(message, highlight) { + this._countError = (message, highlight) => { if (/\b(Error|Warning)Msg\b/.test(highlight)) - self.errors.push(String(message)); + this.errors.push(String(message)); } this.modules.dactyl.registerObserver("beep", this._countBeep); this.modules.dactyl.registerObserver("echoLine", this._countError); @@ -251,8 +250,7 @@ Controller.prototype = { * @param {string} message The message to display upon assertion failure. @optional */ wrapAssertNoErrors: function (func, message) { - let self = this; - return function wrapped() self.assertNoErrors(func, this, arguments, message); + return () => this.assertNoErrors(func, this, arguments, message); }, /**