@@ -165,39 +165,41 @@ kbd {
165
165
`
166
166
167
167
// Error Template
168
- const template = h (
169
- 'div' ,
170
- { class : 'backdrop' , part : 'backdrop' } ,
168
+ let template : HTMLElement
169
+ const createTemplate = ( ) =>
171
170
h (
172
171
'div' ,
173
- { class : 'window' , part : 'window' } ,
174
- h (
175
- 'pre' ,
176
- { class : 'message' , part : 'message' } ,
177
- h ( 'span' , { class : 'plugin' , part : 'plugin' } ) ,
178
- h ( 'span' , { class : 'message-body' , part : 'message-body' } ) ,
179
- ) ,
180
- h ( 'pre' , { class : 'file' , part : 'file' } ) ,
181
- h ( 'pre' , { class : 'frame' , part : 'frame' } ) ,
182
- h ( 'pre' , { class : 'stack' , part : 'stack' } ) ,
172
+ { class : 'backdrop' , part : 'backdrop' } ,
183
173
h (
184
174
'div' ,
185
- { class : 'tip' , part : 'tip' } ,
186
- 'Click outside, press ' ,
187
- h ( 'kbd' , { } , 'Esc' ) ,
188
- ' key, or fix the code to dismiss.' ,
189
- h ( 'br' ) ,
190
- 'You can also disable this overlay by setting ' ,
191
- h ( 'code' , { part : 'config-option-name' } , 'server.hmr.overlay' ) ,
192
- ' to ' ,
193
- h ( 'code' , { part : 'config-option-value' } , 'false' ) ,
194
- ' in ' ,
195
- h ( 'code' , { part : 'config-file-name' } , hmrConfigName ) ,
196
- '.' ,
175
+ { class : 'window' , part : 'window' } ,
176
+ h (
177
+ 'pre' ,
178
+ { class : 'message' , part : 'message' } ,
179
+ h ( 'span' , { class : 'plugin' , part : 'plugin' } ) ,
180
+ h ( 'span' , { class : 'message-body' , part : 'message-body' } ) ,
181
+ ) ,
182
+ h ( 'pre' , { class : 'file' , part : 'file' } ) ,
183
+ h ( 'pre' , { class : 'frame' , part : 'frame' } ) ,
184
+ h ( 'pre' , { class : 'stack' , part : 'stack' } ) ,
185
+ h (
186
+ 'div' ,
187
+ { class : 'tip' , part : 'tip' } ,
188
+ 'Click outside, press ' ,
189
+ h ( 'kbd' , { } , 'Esc' ) ,
190
+ ' key, or fix the code to dismiss.' ,
191
+ h ( 'br' ) ,
192
+ 'You can also disable this overlay by setting ' ,
193
+ h ( 'code' , { part : 'config-option-name' } , 'server.hmr.overlay' ) ,
194
+ ' to ' ,
195
+ h ( 'code' , { part : 'config-option-value' } , 'false' ) ,
196
+ ' in ' ,
197
+ h ( 'code' , { part : 'config-file-name' } , hmrConfigName ) ,
198
+ '.' ,
199
+ ) ,
197
200
) ,
198
- ) ,
199
- h ( 'style' , { } , templateStyle ) ,
200
- )
201
+ h ( 'style' , { } , templateStyle ) ,
202
+ )
201
203
202
204
const fileRE = / (?: [ a - z A - Z ] : \\ | \/ ) .* ?: \d + : \d + / g
203
205
const codeframeRE = / ^ (?: > ? \s * \d + \s + \| .* | \s + \| \s * \^ .* ) \r ? \n / gm
@@ -213,6 +215,7 @@ export class ErrorOverlay extends HTMLElement {
213
215
super ( )
214
216
this . root = this . attachShadow ( { mode : 'open' } )
215
217
218
+ template ??= createTemplate ( )
216
219
this . root . appendChild ( template )
217
220
218
221
codeframeRE . lastIndex = 0
0 commit comments