Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Properly remove request indicators #2860

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@
*/
function makeFragment(response) {
// strip head tag to determine shape of response we are dealing with
const responseWithNoHead = response.replace(/<head(\s[^>]*)?>.*?<\/head>/is, '')

Check failure on line 586 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

This regular expression flag is only available when targeting 'es2018' or later.
const startTag = getStartTag(responseWithNoHead)
/** @type DocumentFragmentWithTitle */
let fragment
Expand Down Expand Up @@ -3269,16 +3269,18 @@
* @param {Element[]} disabled
*/
function removeRequestIndicators(indicators, disabled) {
forEach(indicators.concat(disabled), function(ele) {
const internalData = getInternalData(ele)
internalData.requestCount = (internalData.requestCount || 1) - 1
})
forEach(indicators, function(ic) {
const internalData = getInternalData(ic)
internalData.requestCount = (internalData.requestCount || 1) - 1
if (internalData.requestCount === 0) {
ic.classList.remove.call(ic.classList, htmx.config.requestClass)
}
})
forEach(disabled, function(disabledElement) {
const internalData = getInternalData(disabledElement)
internalData.requestCount = (internalData.requestCount || 1) - 1
if (internalData.requestCount === 0) {
disabledElement.removeAttribute('disabled')
disabledElement.removeAttribute('data-disabled-by-htmx')
Expand Down
Loading