Use let/const instead of var
This commit is contained in:
parent
3053be345b
commit
712b15286c
4 changed files with 85 additions and 100 deletions
|
@ -6,9 +6,9 @@ const webViewConstants = require('./web-view-constants')
|
|||
const remote = require('electron').remote
|
||||
|
||||
// Helper function to resolve url set in attribute.
|
||||
var a = document.createElement('a')
|
||||
const a = document.createElement('a')
|
||||
|
||||
var resolveURL = function (url) {
|
||||
const resolveURL = function (url) {
|
||||
if (url === '') return ''
|
||||
a.href = url
|
||||
return a.href
|
||||
|
@ -211,9 +211,8 @@ class SrcAttribute extends WebViewAttribute {
|
|||
// where the webview guest has crashed and navigating to the same address
|
||||
// spawns off a new process.
|
||||
setupMutationObserver () {
|
||||
var params
|
||||
this.observer = new MutationObserver((mutations) => {
|
||||
var i, len, mutation, newValue, oldValue
|
||||
let i, len, mutation, newValue, oldValue
|
||||
for (i = 0, len = mutations.length; i < len; i++) {
|
||||
mutation = mutations[i]
|
||||
oldValue = mutation.oldValue
|
||||
|
@ -224,7 +223,7 @@ class SrcAttribute extends WebViewAttribute {
|
|||
this.handleMutation(oldValue, newValue)
|
||||
}
|
||||
})
|
||||
params = {
|
||||
const params = {
|
||||
attributes: true,
|
||||
attributeOldValue: true,
|
||||
attributeFilter: [this.name]
|
||||
|
@ -233,7 +232,6 @@ class SrcAttribute extends WebViewAttribute {
|
|||
}
|
||||
|
||||
parse () {
|
||||
var guestContents, httpreferrer, opts, useragent
|
||||
if (!this.webViewImpl.elementAttached || !this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId || !this.getValue()) {
|
||||
return
|
||||
}
|
||||
|
@ -246,16 +244,16 @@ class SrcAttribute extends WebViewAttribute {
|
|||
}
|
||||
|
||||
// Navigate to |this.src|.
|
||||
opts = {}
|
||||
httpreferrer = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
||||
const opts = {}
|
||||
const httpreferrer = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
||||
if (httpreferrer) {
|
||||
opts.httpReferrer = httpreferrer
|
||||
}
|
||||
useragent = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_USERAGENT].getValue()
|
||||
const useragent = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_USERAGENT].getValue()
|
||||
if (useragent) {
|
||||
opts.userAgent = useragent
|
||||
}
|
||||
guestContents = remote.getGuestWebContents(this.webViewImpl.guestInstanceId)
|
||||
const guestContents = remote.getGuestWebContents(this.webViewImpl.guestInstanceId)
|
||||
guestContents.loadURL(this.getValue(), opts)
|
||||
}
|
||||
}
|
||||
|
@ -281,12 +279,11 @@ class PreloadAttribute extends WebViewAttribute {
|
|||
}
|
||||
|
||||
getValue () {
|
||||
var preload, protocol
|
||||
if (!this.webViewImpl.webviewNode.hasAttribute(this.name)) {
|
||||
return this.value
|
||||
}
|
||||
preload = resolveURL(this.webViewImpl.webviewNode.getAttribute(this.name))
|
||||
protocol = preload.substr(0, 5)
|
||||
let preload = resolveURL(this.webViewImpl.webviewNode.getAttribute(this.name))
|
||||
const protocol = preload.substr(0, 5)
|
||||
if (protocol !== 'file:') {
|
||||
console.error(webViewConstants.ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE)
|
||||
preload = ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue