summaryrefslogtreecommitdiffstats
path: root/browser
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-04-20 20:16:18 -0400
committerMatt A. Tobin <email@mattatobin.com>2018-04-20 20:16:18 -0400
commit94a484dd7e224ef6f4fc5994fa50478d41f72638 (patch)
tree5d91fbb0d1ebeeb1cf0a9ab266effb29ce4c1764 /browser
parent754ad610489603f80ea38bbd2cf18b28f0d8bf1d (diff)
parentb3bf60f4264b9acfbd2cb34fed4a66915012803c (diff)
downloadUXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar.gz
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar.lz
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.tar.xz
UXP-94a484dd7e224ef6f4fc5994fa50478d41f72638.zip
Merge branch 'master' into xulrunner
Diffstat (limited to 'browser')
-rw-r--r--browser/components/webextensions/ext-commands.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/browser/components/webextensions/ext-commands.js b/browser/components/webextensions/ext-commands.js
index 416544e86..3f0bf8d1a 100644
--- a/browser/components/webextensions/ext-commands.js
+++ b/browser/components/webextensions/ext-commands.js
@@ -74,15 +74,14 @@ CommandList.prototype = {
// For Windows, chrome.runtime expects 'win' while chrome.commands
// expects 'windows'. We can special case this for now.
let os = PlatformInfo.os == "win" ? "windows" : PlatformInfo.os;
- for (let name of Object.keys(manifest.commands)) {
- let command = manifest.commands[name];
- let shortcut = command.suggested_key[os] || command.suggested_key.default;
- if (shortcut) {
- commands.set(name, {
- description: command.description,
- shortcut: shortcut.replace(/\s+/g, ""),
- });
- }
+ for (let [name, command] of Object.entries(manifest.commands)) {
+ let suggested_key = command.suggested_key || {};
+ let shortcut = suggested_key[os] || suggested_key.default;
+ shortcut = shortcut ? shortcut.replace(/\s+/g, "") : null;
+ commands.set(name, {
+ description: command.description,
+ shortcut,
+ });
}
return commands;
},
@@ -96,8 +95,10 @@ CommandList.prototype = {
let keyset = doc.createElementNS(XUL_NS, "keyset");
keyset.id = `ext-keyset-id-${this.id}`;
this.commands.forEach((command, name) => {
- let keyElement = this.buildKey(doc, name, command.shortcut);
- keyset.appendChild(keyElement);
+ if (command.shortcut) {
+ let keyElement = this.buildKey(doc, name, command.shortcut);
+ keyset.appendChild(keyElement);
+ }
});
doc.documentElement.appendChild(keyset);
this.keysetsMap.set(window, keyset);