From b54b74c31023798e9d896c38a782e79669c63d3d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 6 Sep 2016 11:31:14 -0700 Subject: [PATCH] Prevent missing Menu.buildFromTemplate function --- lib/browser/api/web-contents.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index eba951b6d7d5..560b323d619b 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -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) })