From 6ff4ebe97dde7c0253d1675c8aaafd8f7ae3de81 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 9 Jun 2026 23:41:31 -0700 Subject: [PATCH] Only reset checkboxes if `type` has changed If a user is entering several files of the same type, the user likely wants the same settings (for example, `modulepreload` for all JS files). It is annoying to force the user to keep re-checking the boxes. --- index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 7753038..175720b 100644 --- a/index.html +++ b/index.html @@ -246,13 +246,15 @@ } } + let previousType = ''; form.addEventListener('submit', async e => { e.preventDefault(); const { url, sriHash, preload, esm } = e.target.elements; const { type, ...sri } = await getSri(url.value); - // Reset checkboxes if form submitted via "Hash!" button - if (e?.submitter?.tagName === 'BUTTON') { + // Reset checkboxes if form submitted via "Hash!" button and type has changed + if (e?.submitter?.tagName === 'BUTTON' && type !== previousType) { + previousType = type; preload.checked = false; esm.checked = false; if (type === 'text/javascript' || type === 'application/javascript') { -- 2.47.3