mirror of
https://github.com/ae-utbm/sith.git
synced 2026-09-09 14:04:36 +00:00
Merge pull request #1482 from ae-utbm/htmx4-aria-busy-plugin
Fix aria-busy during swap and make it a plugin
This commit is contained in:
@@ -48,19 +48,26 @@ polyfillCountryFlagEmojis();
|
|||||||
/**
|
/**
|
||||||
* HTMX
|
* HTMX
|
||||||
*/
|
*/
|
||||||
document.body.addEventListener(
|
htmx.registerExtension("aria-busy", {
|
||||||
"htmx:before:request" as keyof HTMLElementEventMap,
|
// biome-ignore lint/style/useNamingConvention: api's name
|
||||||
(event) => {
|
htmx_before_request: (
|
||||||
(event as CustomEvent).detail.ctx.target.ariaBusy = true;
|
_: HTMLElement,
|
||||||
|
detail: { ctx: { target: HTMLElement | undefined } },
|
||||||
|
) => {
|
||||||
|
if (detail.ctx.target !== undefined) {
|
||||||
|
(detail.ctx.target as HTMLElement).ariaBusy = "true";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
// biome-ignore lint/style/useNamingConvention: api's name
|
||||||
|
htmx_after_swap: (
|
||||||
document.body.addEventListener(
|
_: HTMLElement,
|
||||||
"htmx:before:swap" as keyof HTMLElementEventMap,
|
detail: { ctx: { target: HTMLElement | undefined } },
|
||||||
(event) => {
|
) => {
|
||||||
(event as CustomEvent).detail.ctx.target.ariaBusy = null;
|
if (detail.ctx.target !== undefined) {
|
||||||
|
(detail.ctx.target as HTMLElement).ariaBusy = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
Object.assign(window, { htmx });
|
Object.assign(window, { htmx });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user