Use for/of and remove loop variables
This commit is contained in:
parent
6eab14359c
commit
0e1c2b0fcb
3 changed files with 13 additions and 20 deletions
|
@ -44,16 +44,13 @@ const DEPRECATED_EVENTS = {
|
|||
}
|
||||
|
||||
const dispatchEvent = function (webView, eventName, eventKey, ...args) {
|
||||
let f, i, j, len
|
||||
if (DEPRECATED_EVENTS[eventName] != null) {
|
||||
dispatchEvent.apply(null, [webView, DEPRECATED_EVENTS[eventName], eventKey].concat(args))
|
||||
dispatchEvent(webView, DEPRECATED_EVENTS[eventName], eventKey, ...args)
|
||||
}
|
||||
const domEvent = new Event(eventName)
|
||||
const props = WEB_VIEW_EVENTS[eventKey]
|
||||
for (i = j = 0, len = props.length; j < len; i = ++j) {
|
||||
f = props[i]
|
||||
domEvent[f] = args[i]
|
||||
}
|
||||
WEB_VIEW_EVENTS[eventKey].forEach((prop, index) => {
|
||||
domEvent[prop] = args[index]
|
||||
})
|
||||
webView.dispatchEvent(domEvent)
|
||||
if (eventName === 'load-commit') {
|
||||
webView.onLoadCommit(domEvent)
|
||||
|
@ -82,12 +79,11 @@ module.exports = {
|
|||
})
|
||||
|
||||
ipcRenderer.on(`ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-${viewInstanceId}`, function (event, ...args) {
|
||||
let f, i, j, len
|
||||
const domEvent = new Event('size-changed')
|
||||
const props = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight']
|
||||
for (i = j = 0, len = props.length; j < len; i = ++j) {
|
||||
f = props[i]
|
||||
domEvent[f] = args[i]
|
||||
for (let i = 0; i < props.length; i++) {
|
||||
const prop = props[i]
|
||||
domEvent[prop] = args[i]
|
||||
}
|
||||
webView.onSizeChanged(domEvent)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue