diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 5e95aa2e01c9..0524c43942cb 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -82,7 +82,7 @@ BrowserWindow.prototype._init = function () { let isVisible = this.isVisible() && !this.isMinimized() let visibilityChanged = () => { let newState = this.isVisible() && !this.isMinimized() - if (isVisible != newState) { + if (isVisible !== newState) { isVisible = newState this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', isVisible ? 'visible' : 'hidden') } @@ -94,8 +94,9 @@ BrowserWindow.prototype._init = function () { this.on('maximize', visibilityChanged) // Make renderer process have correct initial state. - if (!isVisible) + if (!isVisible) { this.webContents.mergeWebPreferences({visibilityState: 'hidden'}) + } // Notify the creation of the window. app.emit('browser-window-created', {}, this) diff --git a/lib/renderer/override.js b/lib/renderer/override.js index 4b86a74de78c..1d01d2b5b759 100644 --- a/lib/renderer/override.js +++ b/lib/renderer/override.js @@ -232,7 +232,7 @@ if (process.visibilityState) { // Subscribe to visibilityState changes. ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, visibilityState) { - if (cachedVisibilityState != visibilityState) { + if (cachedVisibilityState !== visibilityState) { cachedVisibilityState = visibilityState document.dispatchEvent(new Event('visibilitychange')) } @@ -241,7 +241,7 @@ ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, vi // Make document.hidden and document.visibilityState return the correct value. Object.defineProperty(document, 'hidden', { get: function () { - return cachedVisibilityState != 'visible' + return cachedVisibilityState !== 'visible' } })