Prevent missing Menu.buildFromTemplate function

This commit is contained in:
Kevin Sawicki 2016-09-06 11:31:14 -07:00
parent 02ce727ff6
commit b54b74c310

View file

@ -1,7 +1,8 @@
'use strict'
const {EventEmitter} = require('events')
const {app, ipcMain, session, Menu, NavigationController} = require('electron')
const electron = require('electron')
const {app, ipcMain, session, NavigationController} = electron
// session is not used here, the purpose is to make sure session is initalized
// before the webContents module.
@ -220,7 +221,8 @@ WebContents.prototype._init = function () {
// Handle context menu action request from pepper plugin.
this.on('pepper-context-menu', function (event, params) {
const menu = Menu.buildFromTemplate(params.menu)
// Access Menu via electron.Menu to prevent circular require
const menu = electron.Menu.buildFromTemplate(params.menu)
menu.popup(params.x, params.y)
})