factor out parse-features-string.js
This commit is contained in:
parent
e7962c7ba2
commit
f35536bdc5
3 changed files with 35 additions and 29 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
const ipcRenderer = require('electron').ipcRenderer
|
||||
const remote = require('electron').remote
|
||||
const parseFeaturesString = require('../common/parse-features-string')
|
||||
|
||||
// Helper function to resolve relative url.
|
||||
var a = window.top.document.createElement('a')
|
||||
|
@ -104,27 +105,21 @@ window.open = function (url, frameName, features) {
|
|||
// Used to store additional features
|
||||
additionalFeatures = []
|
||||
|
||||
// Make sure to get rid of excessive whitespace in the property name
|
||||
ref1 = features.split(/,\s*/)
|
||||
for (i = 0, len = ref1.length; i < len; i++) {
|
||||
feature = ref1[i]
|
||||
ref2 = feature.split(/\s*=/)
|
||||
name = ref2[0]
|
||||
value = ref2[1]
|
||||
value = value === 'yes' || value === '1' ? true : value === 'no' || value === '0' ? false : value
|
||||
// Parse the features
|
||||
parseFeaturesString(features, function (key, value) {
|
||||
if (value === undefined) {
|
||||
additionalFeatures.push(feature)
|
||||
additionalFeatures.push(key)
|
||||
} else {
|
||||
if (webPreferences.includes(name)) {
|
||||
if (webPreferences.includes(key)) {
|
||||
if (options.webPreferences == null) {
|
||||
options.webPreferences = {}
|
||||
}
|
||||
options.webPreferences[name] = value
|
||||
options.webPreferences[key] = value
|
||||
} else {
|
||||
options[name] = value
|
||||
options[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
if (options.left) {
|
||||
if (options.x == null) {
|
||||
options.x = options.left
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue