File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,10 @@ export class IncludeFragmentElement extends HTMLElement {
234
234
try {
235
235
await this . #task( [ 'loadstart' ] )
236
236
const response = await this . fetch ( this . request ( ) )
237
+ const ct = response . headers . get ( 'Content-Type' )
238
+ if ( ! isWildcard ( this . accept ) && ( ! ct || ! ct . includes ( this . accept ? this . accept : 'text/html' ) ) ) {
239
+ throw new Error ( `Failed to load resource: expected ${ this . accept || 'text/html' } but was ${ ct } ` )
240
+ }
237
241
if ( response . status !== 200 ) {
238
242
throw new Error ( `Failed to load resource: the server responded with a status of ${ response . status } ` )
239
243
}
@@ -255,10 +259,6 @@ export class IncludeFragmentElement extends HTMLElement {
255
259
// the `load()` promise to resolve _before_ these
256
260
// events are fired.
257
261
this . #task( [ 'error' , 'loadend' ] , error as Error )
258
- const ct = response . headers . get ( 'Content-Type' )
259
- if ( ! isWildcard ( this . accept ) && ( ! ct || ! ct . includes ( this . accept ? this . accept : 'text/html' ) ) ) {
260
- throw new Error ( `Failed to load resource: expected ${ this . accept || 'text/html' } but was ${ ct } ` )
261
- }
262
262
throw error
263
263
}
264
264
}
You can’t perform that action at this time.
0 commit comments