diff --git a/src/htmx.js b/src/htmx.js index ad779a91..973f3d4a 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -2050,6 +2050,10 @@ return (function () { triggerErrorEvent(elt, 'htmx:sendError', eventDetail); endRequestLock(); } + xhr.onabort = function() { + removeRequestIndicatorClasses(elt); + endRequestLock(); + } if(!triggerEvent(elt, 'htmx:beforeRequest', eventDetail)) return endRequestLock(); addRequestIndicatorClasses(elt); diff --git a/test/index.html b/test/index.html index 9aa54739..0d39702a 100644 --- a/test/index.html +++ b/test/index.html @@ -51,6 +51,9 @@
  • SSE - Settling
  • +
  • + Aborting Request Test +
  • Mocha Test Suite

    diff --git a/test/manual/aborting-request.html b/test/manual/aborting-request.html new file mode 100644 index 00000000..08e264d6 --- /dev/null +++ b/test/manual/aborting-request.html @@ -0,0 +1,36 @@ + + + + + Aborting Request Event Test + + +

    Aborting Request Event Tests

    +

    Aborting a request during an HTMX event should not prevent future events from firing.

    + + +

    + +

    +

    Event Messages:

    +
    + + + + \ No newline at end of file