Remove deprecated options check in BrowserWindow

This commit is contained in:
Kevin Sawicki 2016-04-28 09:42:06 -07:00
parent 0342db9328
commit 6f0471f6cb
2 changed files with 1 additions and 72 deletions

View file

@ -1,9 +1,8 @@
'use strict'
const ipcMain = require('electron').ipcMain
const deprecate = require('electron').deprecate
const EventEmitter = require('events').EventEmitter
const {BrowserWindow, _setDeprecatedOptionsCheck} = process.atomBinding('window')
const {BrowserWindow} = process.atomBinding('window')
Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype)
@ -196,56 +195,4 @@ BrowserWindow.prototype.inspectServiceWorker = function () {
return this.webContents.inspectServiceWorker()
}
const isDeprecatedKey = function (key) {
return key.indexOf('-') >= 0
}
// Map deprecated key with hyphens to camel case key
const getNonDeprecatedKey = function (deprecatedKey) {
return deprecatedKey.replace(/-./g, function (match) {
return match[1].toUpperCase()
})
}
// TODO Remove for 1.0
const checkForDeprecatedOptions = function (options) {
if (!options) return ''
let keysToCheck = Object.keys(options)
if (options.webPreferences) {
keysToCheck = keysToCheck.concat(Object.keys(options.webPreferences))
}
// Check options for keys with hyphens in them
let deprecatedKey = keysToCheck.filter(isDeprecatedKey)[0]
if (deprecatedKey) {
try {
deprecate.warn(deprecatedKey, getNonDeprecatedKey(deprecatedKey))
} catch (error) {
// Return error message so it can be rethrown via C++
return error.message
}
}
let webPreferenceOption
if (options.hasOwnProperty('nodeIntegration')) {
webPreferenceOption = 'nodeIntegration'
} else if (options.hasOwnProperty('preload')) {
webPreferenceOption = 'preload'
} else if (options.hasOwnProperty('zoomFactor')) {
webPreferenceOption = 'zoomFactor'
}
if (webPreferenceOption) {
try {
deprecate.warn(`options.${webPreferenceOption}`, `options.webPreferences.${webPreferenceOption}`)
} catch (error) {
// Return error message so it can be rethrown via C++
return error.message
}
}
return ''
}
_setDeprecatedOptionsCheck(checkForDeprecatedOptions)
module.exports = BrowserWindow