]> git.ardis.lu - minimal-srihash/commitdiff
Only reset checkboxes if `type` has changed
authorArdis Lu <ardisglu@gmail.com>
Wed, 10 Jun 2026 06:41:31 +0000 (23:41 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 10 Jun 2026 06:41:31 +0000 (23:41 -0700)
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

index 7753038386355e2656aeec1a13f9e2f0da51f0ce..175720b602dc7e6dadbab1b48361e7f37c5caf54 100644 (file)
       }
     }
 
+    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') {
This page took 0.033789 seconds and 4 git commands to generate.