From 8a3e01133fa772ea01588d171d9901b063b776de Mon Sep 17 00:00:00 2001 From: Wessie Date: Wed, 6 Mar 2024 20:06:47 +0000 Subject: [PATCH] website/js: fix htmx sse extension (again) The fix we're after was in this file, but it depended on some htmx 2.0 API, which isn't released yet. This patches the part that uses the new API to use the old version instead. We can upgrade later to the proper version --- assets/js/htmx-sse.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/assets/js/htmx-sse.js b/assets/js/htmx-sse.js index 4e237c20..2af654fe 100644 --- a/assets/js/htmx-sse.js +++ b/assets/js/htmx-sse.js @@ -269,7 +269,23 @@ This extension adds support for Server Sent Events to htmx. See /www/extensions var swapSpec = api.getSwapSpecification(elt) var target = api.getTarget(elt) - api.swap(target, content, swapSpec) + var settleInfo = api.makeSettleInfo(elt) + + api.selectAndSwap(swapSpec.swapStyle, target, elt, content, settleInfo) + + settleInfo.elts.forEach(function (elt) { + if (elt.classList) { + elt.classList.add(htmx.config.settlingClass) + } + api.triggerEvent(elt, 'htmx:beforeSettle') + }) + + // Handle settle tasks (with delay if requested) + if (swapSpec.settleDelay > 0) { + setTimeout(doSettle(settleInfo), swapSpec.settleDelay) + } else { + doSettle(settleInfo)() + } } /**