@@ -364,19 +364,16 @@ const api = {
364
364
365
365
let displayURL = newTab . getURL ( )
366
366
let location = displayURL || 'about:blank'
367
-
368
367
const openerTabId = ! source . isDestroyed ( ) ? source . getId ( ) : - 1
369
- let newTabValue = getTabValue ( newTab . getId ( ) )
370
368
371
369
let rendererInitiated = false
372
370
if ( source . isGuest ( ) ) {
373
371
rendererInitiated = true
374
372
}
375
373
376
- let index
377
- if ( parseInt ( newTabValue . get ( 'index' ) ) > - 1 ) {
378
- index = newTabValue . get ( 'index' )
379
- }
374
+ const tabId = newTab . getId ( )
375
+ updateWebContents ( tabId , newTab )
376
+ let newTabValue = getTabValue ( newTab . getId ( ) )
380
377
381
378
let windowId
382
379
if ( newTabValue && parseInt ( newTabValue . get ( 'windowId' ) ) > - 1 ) {
@@ -386,6 +383,11 @@ const api = {
386
383
windowId = hostWebContents . getOwnerBrowserWindow ( ) . id
387
384
}
388
385
386
+ let index
387
+ if ( parseInt ( newTabValue . get ( 'index' ) ) > - 1 ) {
388
+ index = newTabValue . get ( 'index' )
389
+ }
390
+
389
391
const frameOpts = {
390
392
location,
391
393
displayURL,
@@ -397,14 +399,17 @@ const api = {
397
399
openerTabId,
398
400
disposition,
399
401
index,
400
- tabId : newTabValue . get ( 'id' ) ,
402
+ tabId,
401
403
unloaded : ! ! newTabValue . get ( 'discarded' )
402
404
}
403
405
406
+ appActions . tabCreated ( newTabValue )
407
+
404
408
if ( disposition === 'new-window' || disposition === 'new-popup' ) {
405
409
const windowOpts = makeImmutable ( size )
406
410
appActions . newWindow ( makeImmutable ( frameOpts ) , windowOpts )
407
411
} else {
412
+ // TODO(bridiver) - use tabCreated in place of newWebContentsAdded
408
413
appActions . newWebContentsAdded ( windowId , frameOpts , newTabValue )
409
414
}
410
415
} )
@@ -476,13 +481,6 @@ const api = {
476
481
windowActions . gotResponseDetails ( tabId , { status, newURL, originalURL, httpResponseCode, requestMethod, referrer, headers, resourceType} )
477
482
}
478
483
} )
479
-
480
- updateWebContents ( tabId , tab )
481
-
482
- let tabValue = getTabValue ( tabId )
483
- if ( tabValue ) {
484
- appActions . tabCreated ( tabValue )
485
- }
486
484
} )
487
485
488
486
process . on ( 'on-tab-created' , ( tab , options ) => {
0 commit comments