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 @@ -237,10 +237,6 @@ export class IncludeFragmentElement extends HTMLElement {
237237 if ( response . status !== 200 ) {
238238 throw new Error ( `Failed to load resource: the server responded with a status of ${ response . status } ` )
239239 }
240- const ct = response . headers . get ( 'Content-Type' )
241- if ( ! isWildcard ( this . accept ) && ( ! ct || ! ct . includes ( this . accept ? this . accept : 'text/html' ) ) ) {
242- throw new Error ( `Failed to load resource: expected ${ this . accept || 'text/html' } but was ${ ct } ` )
243- }
244240
245241 const responseText : string = await response . text ( )
246242 let data : string | CSPTrustedHTMLToStringable = responseText
@@ -259,6 +255,10 @@ export class IncludeFragmentElement extends HTMLElement {
259255 // the `load()` promise to resolve _before_ these
260256 // events are fired.
261257 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+ }
262262 throw error
263263 }
264264 }
You can’t perform that action at this time.
0 commit comments