]> git.ardis.lu - event-hashes/commitdiff
Remove ClipboardItem fallback
authorArdis Lu <ardisglu@gmail.com>
Wed, 21 Aug 2024 05:17:14 +0000 (22:17 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 21 Aug 2024 05:17:14 +0000 (22:17 -0700)
ClipboardItem is supported on all modern web browsers as of June 2024

index.html

index 0a2f7dbab48783e428d41b3f6f19b10317551b19..6ec6f9e959f5b0a2c838d8cd98284a124437c42f 100644 (file)
     });
 
     document.querySelector('#copy-table').addEventListener('click', e => {
-      if (window.ClipboardItem === undefined) {
-        navigator.clipboard.writeText(table.innerText);
-      }
-      else {
-        const data = [new ClipboardItem({
-          'text/plain': new Blob([table.innerText], { type: 'text/plain' }),
-          'text/html': new Blob([`<style>table{white-space:nowrap;border-collapse:collapse;mso-ascii-theme-font:minor-latin;}th,td{mso-border-alt:solid windowtext .5pt;}thead{background:#E8E8E8;}</style>${table.outerHTML}`], { type: 'text/html' })
-        })];
-        navigator.clipboard.write(data);
-      }
+      const data = [new ClipboardItem({
+        'text/plain': new Blob([table.innerText], { type: 'text/plain' }),
+        'text/html': new Blob([`<style>table{white-space:nowrap;border-collapse:collapse;mso-ascii-theme-font:minor-latin;}th,td{mso-border-alt:solid windowtext .5pt;}thead{background:#E8E8E8;}</style>${table.outerHTML}`], { type: 'text/html' })
+      })];
+      navigator.clipboard.write(data);
       debounceButton(e.target, icons['clipboard'], 'Copy table to clipboard');
     });
 
This page took 0.037553 seconds and 4 git commands to generate.