Merge pull request #11532 from sethlu/camelcase-menuitem-role

Make MenuItem roles camelCase-compatible
This commit is contained in:
Zeke Sikelianos 2018-01-04 09:53:58 -08:00 committed by GitHub
commit eb89e12c5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 24 deletions

View file

@ -162,7 +162,7 @@ const roles = {
}
},
// Edit submenu (should fit both Mac & Windows)
editMenu: {
editmenu: {
label: 'Edit',
submenu: [
{
@ -185,7 +185,7 @@ const roles = {
},
process.platform === 'darwin' ? {
role: 'pasteandmatchstyle'
role: 'pasteAndMatchStyle'
} : null,
{
@ -197,13 +197,13 @@ const roles = {
} : null,
{
role: 'selectall'
role: 'selectAll'
}
]
},
// Window submenu should be used for Mac only
windowMenu: {
windowmenu: {
label: 'Window',
submenu: [
{

View file

@ -11,6 +11,9 @@ const MenuItem = function (options) {
for (let key in options) {
if (!(key in this)) this[key] = options[key]
}
if (typeof this.role === 'string' || this.role instanceof String) {
this.role = this.role.toLowerCase()
}
this.submenu = this.submenu || roles.getDefaultSubmenu(this.role)
if (this.submenu != null && this.submenu.constructor !== Menu) {
this.submenu = Menu.buildFromTemplate(this.submenu)