@@ -37,25 +37,28 @@ type WebViewProps = {
37
37
export default class WebView {
38
38
static templateHtml ( props : WebViewProps ) : Html {
39
39
return html `
40
- < webview
41
- data-tab-id ="${ props . tabIndex } "
42
- src ="${ props . url } "
43
- ${ props . preload === undefined
44
- ? html ``
45
- : html `preload ="${ props . preload } "` }
46
- partition ="persist:webviewsession "
47
- allowpopups
48
- >
49
- </ webview >
40
+ < div class ="webview-pane ">
41
+ < webview
42
+ data-tab-id ="${ props . tabIndex } "
43
+ src ="${ props . url } "
44
+ ${ props . preload === undefined
45
+ ? html ``
46
+ : html `preload ="${ props . preload } "` }
47
+ partition ="persist:webviewsession "
48
+ allowpopups
49
+ >
50
+ </ webview >
51
+ </ div >
50
52
` ;
51
53
}
52
54
53
55
static async create ( props : WebViewProps ) : Promise < WebView > {
54
- const $webview = generateNodeFromHtml (
56
+ const $pane = generateNodeFromHtml (
55
57
WebView . templateHtml ( props ) ,
56
58
) as HTMLElement ;
57
- props . $root . append ( $webview ) ;
59
+ props . $root . append ( $pane ) ;
58
60
61
+ const $webview : HTMLElement = $pane . querySelector ( ":scope > webview" ) ! ;
59
62
await new Promise < void > ( ( resolve ) => {
60
63
$webview . addEventListener (
61
64
"did-attach" ,
@@ -87,7 +90,7 @@ export default class WebView {
87
90
throw new TypeError ( "Failed to get WebContents ID" ) ;
88
91
}
89
92
90
- return new WebView ( props , $webview , webContentsId ) ;
93
+ return new WebView ( props , $pane , $ webview, webContentsId ) ;
91
94
}
92
95
93
96
badgeCount = 0 ;
@@ -98,6 +101,7 @@ export default class WebView {
98
101
99
102
private constructor (
100
103
readonly props : WebViewProps ,
104
+ private readonly $pane : HTMLElement ,
101
105
private readonly $webview : HTMLElement ,
102
106
readonly webContentsId : number ,
103
107
) {
@@ -110,7 +114,7 @@ export default class WebView {
110
114
}
111
115
112
116
destroy ( ) : void {
113
- this . $webview . remove ( ) ;
117
+ this . $pane . remove ( ) ;
114
118
}
115
119
116
120
getWebContents ( ) : WebContents {
@@ -128,7 +132,7 @@ export default class WebView {
128
132
}
129
133
130
134
hide ( ) : void {
131
- this . $webview . classList . remove ( "active" ) ;
135
+ this . $pane . classList . remove ( "active" ) ;
132
136
}
133
137
134
138
load ( ) : void {
@@ -278,7 +282,7 @@ export default class WebView {
278
282
// To show or hide the loading indicator in the active tab
279
283
this . $webviewsContainer . toggle ( "loaded" , ! this . loading ) ;
280
284
281
- this . $webview . classList . add ( "active" ) ;
285
+ this . $pane . classList . add ( "active" ) ;
282
286
this . focus ( ) ;
283
287
this . props . onTitleChange ( ) ;
284
288
// Injecting preload css in webview to override some css rules
0 commit comments