From: Ardis Lu Date: Wed, 21 Aug 2024 05:17:14 +0000 (-0700) Subject: Remove ClipboardItem fallback X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=8feb0ec27e5d14ffda3c143e376c3c8c474e22ea;p=event-hashes Remove ClipboardItem fallback ClipboardItem is supported on all modern web browsers as of June 2024 --- diff --git a/index.html b/index.html index 0a2f7db..6ec6f9e 100644 --- a/index.html +++ b/index.html @@ -479,16 +479,11 @@ }); 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([`${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([`${table.outerHTML}`], { type: 'text/html' }) + })]; + navigator.clipboard.write(data); debounceButton(e.target, icons['clipboard'], 'Copy table to clipboard'); });