fix(web): afterSwap used the pre-swap, now-detached target for outerHTML polls

htmx's outerHTML swap (every polling card, including Executions) removes
the original target node from the DOM as part of the swap, but
htmx:afterSwap's eventInfo.target still points at that dead node -- so
restoreTimeToggles() was querying a detached subtree every poll and never
touching the live buttons. Fall back to the native event target, which
htmx dispatches on the freshly-inserted content, whenever detail.target
is no longer connected.
This commit is contained in:
2026-07-26 01:01:32 +02:00
parent 3d0c32b488
commit be8e65277b
+7
View File
@@ -241,6 +241,13 @@
document.body.addEventListener("htmx:afterSwap", function (evt) {
var target = evt.detail && evt.detail.target;
if (!target || !target.isConnected) {
// eventInfo.target is the pre-swap node. Every polling card swaps
// outerHTML on itself, which detaches that exact node from the DOM --
// detail.target is then a dead subtree forever. evt.target (the native
// dispatch target) is htmx's freshly-inserted element instead.
target = evt.target;
}
if (target && target.id === "action-slot") {
processSlot(target);
}