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 {
234234    try  { 
235235      await  this . #task( [ 'loadstart' ] ) 
236236      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+       } 
237241      if  ( response . status  !==  200 )  { 
238242        throw  new  Error ( `Failed to load resource: the server responded with a status of ${ response . status }  ` ) 
239243      } 
@@ -255,10 +259,6 @@ export class IncludeFragmentElement extends HTMLElement {
255259      // the `load()` promise to resolve _before_ these 
256260      // events are fired. 
257261      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