File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -589,11 +589,27 @@ pub const XMLHttpRequest = struct {
589589 }
590590
591591 fn onErr (self : * XMLHttpRequest , err : anyerror ) void {
592- self .state = .done ;
593592 self .send_flag = false ;
594- self .dispatchEvt ("readystatechange" );
595- self .dispatchProgressEvent ("error" , .{});
596- self .dispatchProgressEvent ("loadend" , .{});
593+
594+ // capture the state before we change it
595+ const s = self .state ;
596+
597+ const is_abort = err == DOMError .Abort ;
598+
599+ if (is_abort ) {
600+ self .state = .unsent ;
601+ } else {
602+ self .state = .done ;
603+ self .dispatchEvt ("error" );
604+ }
605+
606+ if (s != .done or s != .unsent ) {
607+ self .dispatchEvt ("readystatechange" );
608+ if (is_abort ) {
609+ self .dispatchProgressEvent ("abort" , .{});
610+ }
611+ self .dispatchProgressEvent ("loadend" , .{});
612+ }
597613
598614 const level : log.Level = if (err == DOMError .Abort ) .debug else .err ;
599615 log .log (.http , level , "error" , .{
You can’t perform that action at this time.
0 commit comments