@@ -57,7 +57,7 @@ function createView (existingViewId, id, webPreferences, boundsString, events) {
5757 view . webContents . on ( event , function ( e ) {
5858 var args = Array . prototype . slice . call ( arguments ) . slice ( 1 )
5959
60- const eventTarget = getWindowFromViewContents ( view ) || windows . getCurrent ( )
60+ const eventTarget = getWindowFromViewContents ( view . webContents ) || windows . getCurrent ( )
6161
6262 if ( ! eventTarget ) {
6363 //this can happen during shutdown - windows can be destroyed before the corresponding views, and the view can emit an event during that time
@@ -92,7 +92,7 @@ function createView (existingViewId, id, webPreferences, boundsString, events) {
9292 (https://github.com/minbrowser/min/issues/1835)
9393 */
9494 if ( ! details . features ) {
95- const eventTarget = getWindowFromViewContents ( view ) || windows . getCurrent ( )
95+ const eventTarget = getWindowFromViewContents ( view . webContents ) || windows . getCurrent ( )
9696
9797 getWindowWebContents ( eventTarget ) . send ( 'view-event' , {
9898 tabId : id ,
@@ -112,7 +112,7 @@ function createView (existingViewId, id, webPreferences, boundsString, events) {
112112 var popupId = Math . random ( ) . toString ( )
113113 temporaryPopupViews [ popupId ] = view
114114
115- const eventTarget = getWindowFromViewContents ( view ) || windows . getCurrent ( )
115+ const eventTarget = getWindowFromViewContents ( view . webContents ) || windows . getCurrent ( )
116116
117117 getWindowWebContents ( eventTarget ) . send ( 'view-event' , {
118118 tabId : id ,
@@ -135,7 +135,7 @@ function createView (existingViewId, id, webPreferences, boundsString, events) {
135135 return
136136 }
137137
138- const eventTarget = getWindowFromViewContents ( view ) || windows . getCurrent ( )
138+ const eventTarget = getWindowFromViewContents ( view . webContents ) || windows . getCurrent ( )
139139
140140 if ( ! eventTarget ) {
141141 //this can happen during shutdown - windows can be destroyed before the corresponding views, and the view can emit an event during that time
@@ -220,7 +220,7 @@ function createView (existingViewId, id, webPreferences, boundsString, events) {
220220 if ( hasJS !== shouldHaveJS ) {
221221 setTimeout ( function ( ) {
222222 view . webContents . stop ( )
223- const currentWindow = getWindowFromViewContents ( view )
223+ const currentWindow = getWindowFromViewContents ( view . webContents )
224224 destroyView ( id )
225225 const newView = createView ( existingViewId , id , Object . assign ( { } , webPreferences , { javascript : shouldHaveJS } ) , boundsString , events )
226226 loadURLInView ( id , event . url , currentWindow )
@@ -293,8 +293,8 @@ function focusView (id) {
293293 if ( viewMap [ id ] && ( viewMap [ id ] . webContents . getURL ( ) !== '' || viewMap [ id ] . webContents . isLoading ( ) ) ) {
294294 viewMap [ id ] . webContents . focus ( )
295295 return true
296- } else if ( getWindowFromViewContents ( viewMap [ id ] ) ) {
297- getWindowWebContents ( getWindowFromViewContents ( viewMap [ id ] ) ) . focus ( )
296+ } else if ( getWindowFromViewContents ( viewMap [ id ] ?. webContents ) ) {
297+ getWindowWebContents ( getWindowFromViewContents ( viewMap [ id ] ?. webContents ) ) . focus ( )
298298 return true
299299 }
300300}
0 commit comments