Bug 1337457 - Handle missing commands[*].suggested_key r=kmag
Defaulting to "" instead of null because Chrome too defaults to "". MozReview-Commit-ID: 7pJYCzVR4f6
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user