From 932730c012d8a344c31b3a7f310144df5ca4013d Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 11 Mar 2025 19:51:46 +0800 Subject: [PATCH] fix htmx --- web_src/js/features/repo-diff.ts | 4 +++- web_src/js/globals.d.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/repo-diff.ts b/web_src/js/features/repo-diff.ts index 1ecd00f1af..ad1da5c2fa 100644 --- a/web_src/js/features/repo-diff.ts +++ b/web_src/js/features/repo-diff.ts @@ -196,7 +196,9 @@ function initRepoDiffShowMore() { const resp = await response.text(); const respDoc = parseDom(resp, 'text/html'); const respFileBody = respDoc.querySelector('#diff-file-boxes .diff-file-body .file-body'); - el.parentElement.replaceWith(...Array.from(respFileBody.children)); + const respFileBodyChildren = Array.from(respFileBody.children); // respFileBody.children will be empty after replaceWith + el.parentElement.replaceWith(...respFileBodyChildren); + for (const el of respFileBodyChildren) window.htmx.process(el); // FIXME: calling onShowMoreFiles is not quite right here. // But since onShowMoreFiles mixes "init diff box" and "init diff body" together, // so it still needs to call it to make the "ImageDiff" and something similar work. diff --git a/web_src/js/globals.d.ts b/web_src/js/globals.d.ts index 2f8cd98878..9e97ec0492 100644 --- a/web_src/js/globals.d.ts +++ b/web_src/js/globals.d.ts @@ -64,6 +64,7 @@ interface Window { jQuery: typeof import('@types/jquery'), htmx: Omit & { config?: Writable, + process?: (elt: Element | string) => void, }, _globalHandlerErrors: Array & { _inited: boolean,