File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ const codeframeRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm
140
140
const { HTMLElement = class { } as typeof globalThis . HTMLElement } = globalThis
141
141
export class ErrorOverlay extends HTMLElement {
142
142
root : ShadowRoot
143
+ closeOnEsc : ( e : KeyboardEvent ) => void
143
144
144
145
constructor ( err : ErrorPayload [ 'err' ] , links = true ) {
145
146
super ( )
@@ -172,22 +173,17 @@ export class ErrorOverlay extends HTMLElement {
172
173
e . stopPropagation ( )
173
174
} )
174
175
175
- const close = ( ) => {
176
- this . parentNode ?. removeChild ( this )
177
- document . removeEventListener ( 'keydown' , closeOnEsc )
178
- }
179
-
180
176
this . addEventListener ( 'click' , ( ) => {
181
- close ( )
177
+ this . close ( )
182
178
} )
183
179
184
- const closeOnEsc = ( e : KeyboardEvent ) => {
180
+ this . closeOnEsc = ( e : KeyboardEvent ) => {
185
181
if ( e . key === 'Escape' || e . code === 'Escape' ) {
186
- close ( )
182
+ this . close ( )
187
183
}
188
184
}
189
185
190
- document . addEventListener ( 'keydown' , closeOnEsc )
186
+ document . addEventListener ( 'keydown' , this . closeOnEsc )
191
187
}
192
188
193
189
text ( selector : string , text : string , linkFiles = false ) : void {
@@ -215,6 +211,10 @@ export class ErrorOverlay extends HTMLElement {
215
211
}
216
212
}
217
213
}
214
+ close ( ) : void {
215
+ this . parentNode ?. removeChild ( this )
216
+ document . removeEventListener ( 'keydown' , this . closeOnEsc )
217
+ }
218
218
}
219
219
220
220
export const overlayId = 'vite-error-overlay'
You can’t perform that action at this time.
0 commit comments