htmx
htmx copied to clipboard
htmx:beforeSwap event is not emitted for the hx-swap-oob swaps
When response contains hx-swap-oob elements, htmx:beforeSwap event is only emitted for the main content only, while html:afterSwap events are emitted for all the swaps.
In my case I have a main content that is replaced with hx-boost and every response contains 3 additional hx-swap-oob elements to be replaced. I have both listeners for the htmx:beforeSwap and htmx:afterSwapevents and here is how the console.log statements look when request is completed:
Instead of emitting normal beforeSwap and afterSwap events the oob swaps seem to emit special events:
https://github.com/bigskysoftware/htmx/blob/bedee219329117fff8d58e33678d82f7c34b08b5/src/htmx.js#L826-L835
I don't know why the afterSwap is emitted anyways.