Π·Π΅ΡΠΊΠ°Π»ΠΎ ΠΈΠ· https://github.com/electron/electron.git
π¨ Use const and for/of loops
This commit is contained in:
Π ΠΎΠ΄ΠΈΡΠ΅Π»Ρ
3bcb411e28
ΠΠΎΠΌΠΌΠΈΡ
ce1a9740f6
|
@ -57,12 +57,12 @@ var getNextInstanceId = function () {
|
|||
|
||||
// Create a new guest instance.
|
||||
var createGuest = function (embedder, params) {
|
||||
var destroy, destroyEvents, event, fn, guest, i, id, j, len, len1, listeners
|
||||
if (webViewManager == null) {
|
||||
webViewManager = process.atomBinding('web_view_manager')
|
||||
}
|
||||
id = getNextInstanceId(embedder)
|
||||
guest = webContents.create({
|
||||
|
||||
const id = getNextInstanceId(embedder)
|
||||
const guest = webContents.create({
|
||||
isGuest: true,
|
||||
partition: params.partition,
|
||||
embedder: embedder
|
||||
|
@ -73,20 +73,19 @@ var createGuest = function (embedder, params) {
|
|||
}
|
||||
|
||||
// Destroy guest when the embedder is gone or navigated.
|
||||
destroyEvents = ['will-destroy', 'crashed', 'did-navigate']
|
||||
destroy = function () {
|
||||
const destroyEvents = ['will-destroy', 'crashed', 'did-navigate']
|
||||
const destroy = function () {
|
||||
if (guestInstances[id] != null) {
|
||||
return destroyGuest(embedder, id)
|
||||
destroyGuest(embedder, id)
|
||||
}
|
||||
}
|
||||
for (i = 0, len = destroyEvents.length; i < len; i++) {
|
||||
event = destroyEvents[i]
|
||||
for (const event of destroyEvents) {
|
||||
embedder.once(event, destroy)
|
||||
|
||||
// Users might also listen to the crashed event, so We must ensure the guest
|
||||
// is destroyed before users' listener gets called. It is done by moving our
|
||||
// listener to the first one in queue.
|
||||
listeners = embedder._events[event]
|
||||
const listeners = embedder._events[event]
|
||||
if (Array.isArray(listeners)) {
|
||||
moveLastToFirst(listeners)
|
||||
}
|
||||
|
@ -132,13 +131,12 @@ var createGuest = function (embedder, params) {
|
|||
})
|
||||
|
||||
// Dispatch events to embedder.
|
||||
fn = function (event) {
|
||||
return guest.on(event, function (_, ...args) {
|
||||
const fn = function (event) {
|
||||
guest.on(event, function (_, ...args) {
|
||||
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args))
|
||||
})
|
||||
}
|
||||
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
|
||||
event = supportedWebViewEvents[j]
|
||||
for (const event of supportedWebViewEvents) {
|
||||
fn(event)
|
||||
}
|
||||
|
||||
|
@ -151,6 +149,7 @@ var createGuest = function (embedder, params) {
|
|||
guest.on('size-changed', function (_, ...args) {
|
||||
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
|
||||
})
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
|
|
ΠΠ°Π³ΡΡΠ·ΠΊΠ°β¦
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅