docs: clarify afterRequest successful/failed reflect responseHandling rule (#3440)#3770
Open
manwithacat wants to merge 1 commit intobigskysoftware:masterfrom
Conversation
… rule (bigskysoftware#3440) The htmx:afterRequest docs described `detail.successful` and `detail.failed` purely in terms of "20x status code", but the actual logic uses the matched htmx.config.responseHandling rule's `error` flag. When users customize responseHandling to allow non-2xx responses to swap (e.g. `{"code":"...", "swap": true}` without `error: true`), those responses are also marked `successful` — a behavior that surprised the issue reporter. Updates the descriptions of both detail.successful and detail.failed to accurately reference responseHandling, while preserving the default "20x = successful" framing as a parenthetical default-behavior note. Adds an explicit note about the custom responseHandling case. No code change; this aligns documentation with the existing intentional behavior confirmed by @MichaelWest22 in the issue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3440.
The
htmx:afterRequestevent docs describeddetail.successfulanddetail.failedpurely as "true if 20x status code", but the actual code (atsrc/htmx.js:4849, 4893–4894) derives them from the matchedhtmx.config.responseHandlingrule'serrorflag:When users customize
responseHandlingto allow non-2xx responses to swap — for example with{"code":"...", "swap": true}and noerror: true— those responses are also markedsuccessfulinhtmx:afterRequest. The issue reporter was surprised by this. As @MichaelWest22 confirmed in the issue, the behavior is intentional ("If you override the default of what is defined as successful to swap then you would expect this to flow though"); the docs were just incomplete.This PR rewords the descriptions of both
detail.successfulanddetail.failedto:htmx.config.responseHandlingas the source of truth.responseHandlingcase so future users with the same setup don't hit the same surprise.Docs-only — targeting
masterper CONTRIBUTING.md. No code change.