Skip to content

Commit

Permalink
website/js: fix htmx sse extension (again)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Wessie committed Mar 6, 2024
1 parent 64f9750 commit 8a3e011
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion assets/js/htmx-sse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)()
}
}

/**
Expand Down

0 comments on commit 8a3e011

Please sign in to comment.