Skip to content

Align <hx-partial> and hx-swap-oob behavior on empty main swap - #3926

Closed
scriptogre wants to merge 1 commit into
bigskysoftware:four-devfrom
scriptogre:4.0/align-partial-oob-empty-swaps
Closed

Align <hx-partial> and hx-swap-oob behavior on empty main swap#3926
scriptogre wants to merge 1 commit into
bigskysoftware:four-devfrom
scriptogre:4.0/align-partial-oob-empty-swaps

Conversation

@scriptogre

@scriptogre scriptogre commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Why

Main target:

<div id="main-target">Original</div>

hx-swap-oob response:

<div id="oob-target" hx-swap-oob="true">Updated</div>

Result:

<div id="main-target"></div>

<hx-partial> response:

<hx-partial hx-target="#partial-target">Updated</hx-partial>

Result:

<div id="main-target">Original</div>

swapEmpty currently has three states:

  • true clears the main target.
  • false keeps the main target.
  • undefined clears it for hx-swap-oob, but keeps it for <hx-partial>.

The special undefined state is confusing.

Change

Default defaultSwapEmpty to true, so both responses clear the main target (like hx-swap-oob does now), so they at least work consistently.

@scriptogre
scriptogre force-pushed the 4.0/align-partial-oob-empty-swaps branch from 2fb6620 to 8354e55 Compare July 30, 2026 18:58
@scriptogre scriptogre changed the title Align partial and OOB empty swaps Align <hx-partial> and hx-swap-oob empty behaviour Jul 30, 2026
@scriptogre scriptogre changed the title Align <hx-partial> and hx-swap-oob empty behaviour Align <hx-partial> and hx-swap-oob behavior on empty main swap Jul 30, 2026
@scriptogre scriptogre added the htmx 4 Issues specific to htmx version 4 label Jul 30, 2026
@1cg

1cg commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Per discussion in chat, going to keep the asymmetry just needs docs

@1cg 1cg closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

htmx 4 Issues specific to htmx version 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants