File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -178,19 +178,18 @@ export default class IncludeFragmentElement extends HTMLElement {
178178 // We mimic the same event order as <img>, including the spec
179179 // which states events must be dispatched after "queue a task".
180180 // https://www.w3.org/TR/html52/semantics-embedded-content.html#the-img-element
181-
182- await this . #task( [ 'loadstart' ] )
183- const response = await this . fetch ( this . request ( ) )
184- if ( response . status !== 200 ) {
185- throw new Error ( `Failed to load resource: the server responded with a status of ${ response . status } ` )
186- }
187- const ct = response . headers . get ( 'Content-Type' )
188- if ( ! isWildcard ( this . accept ) && ( ! ct || ! ct . includes ( this . accept ? this . accept : 'text/html' ) ) ) {
189- throw new Error ( `Failed to load resource: expected ${ this . accept || 'text/html' } but was ${ ct } ` )
190- }
191- const data = await response . text ( )
192-
193181 try {
182+ await this . #task( [ 'loadstart' ] )
183+ const response = await this . fetch ( this . request ( ) )
184+ if ( response . status !== 200 ) {
185+ throw new Error ( `Failed to load resource: the server responded with a status of ${ response . status } ` )
186+ }
187+ const ct = response . headers . get ( 'Content-Type' )
188+ if ( ! isWildcard ( this . accept ) && ( ! ct || ! ct . includes ( this . accept ? this . accept : 'text/html' ) ) ) {
189+ throw new Error ( `Failed to load resource: expected ${ this . accept || 'text/html' } but was ${ ct } ` )
190+ }
191+ const data = await response . text ( )
192+
194193 // Dispatch `load` and `loadend` async to allow
195194 // the `load()` promise to resolve _before_ these
196195 // events are fired.
You can’t perform that action at this time.
0 commit comments