}
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)
})
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)
})
// spawns off a new process.
setupMutationObserver () {
this.observer = new MutationObserver((mutations) => {
- let i, len, mutation, newValue, oldValue
- for (i = 0, len = mutations.length; i < len; i++) {
- mutation = mutations[i]
- oldValue = mutation.oldValue
- newValue = this.getValue()
+ for (const mutation of mutations) {
+ const {oldValue} = mutation
+ const newValue = this.getValue()
if (oldValue !== newValue) {
return
}
}
}
}
- for (let i = 0, len = methods.length; i < len; i++) {
- const method = methods[i]
+ for (const method of methods) {
proto[method] = createBlockHandler(method)
}
+
const createNonBlockHandler = function (m) {
return function (...args) {
const internal = v8Util.getHiddenValue(this, 'internal')
ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args))
}
}
- for (let j = 0, len1 = nonblockMethods.length; j < len1; j++) {
- const method = nonblockMethods[j]
+ for (const method of nonblockMethods) {
proto[method] = createNonBlockHandler(method)
}