Merge pull request #7110 from electron/circular-menu-require
Prevent circular Menu require
This commit is contained in:
commit
ade60ed482
1 changed files with 4 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const {EventEmitter} = require('events')
|
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
|
// session is not used here, the purpose is to make sure session is initalized
|
||||||
// before the webContents module.
|
// before the webContents module.
|
||||||
|
@ -220,7 +221,8 @@ WebContents.prototype._init = function () {
|
||||||
|
|
||||||
// Handle context menu action request from pepper plugin.
|
// Handle context menu action request from pepper plugin.
|
||||||
this.on('pepper-context-menu', function (event, params) {
|
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)
|
menu.popup(params.x, params.y)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue