diff options
author | New Tobin Paradigm <email@mattatobin.com> | 2018-04-20 17:51:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-20 17:51:40 -0400 |
commit | 68c11d035c78211def675d16ad07bede2732cc1d (patch) | |
tree | cef88965561428deb7bdf814fc8c81d55c4333fe /browser/components/webextensions/ext-commands.js | |
parent | 55b2b54f4328ddc56211e888cb5f369d463346da (diff) | |
parent | 11c9f20ea8e15cb5ef51c5cab0863d311ac00025 (diff) | |
download | UXP-68c11d035c78211def675d16ad07bede2732cc1d.tar UXP-68c11d035c78211def675d16ad07bede2732cc1d.tar.gz UXP-68c11d035c78211def675d16ad07bede2732cc1d.tar.lz UXP-68c11d035c78211def675d16ad07bede2732cc1d.tar.xz UXP-68c11d035c78211def675d16ad07bede2732cc1d.zip |
Merge pull request #218 from janekptacijarabaci/webextensions_commands_1
moebius#219: WebExtensions - add-on throws error on load when suggested_key is null / missing
Diffstat (limited to 'browser/components/webextensions/ext-commands.js')
-rw-r--r-- | browser/components/webextensions/ext-commands.js | 23 |
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); |