Merge pull request #7110 from electron/circular-menu-require

Prevent circular Menu require
This commit is contained in:
Cheng Zhao 2016-09-07 16:32:23 +09:00 committed by GitHub
commit ade60ed482

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)
})