Remove dead code and provide the return value for error detection.

This commit is contained in:
pk
2026-07-12 10:17:35 +02:00
parent 62cdab9f9e
commit 57a26dfdc5
+1 -8
View File
@@ -1,23 +1,16 @@
export const clipboard = function(superClass) { export const clipboard = function(superClass) {
return class extends superClass { return class extends superClass {
copy(content) { copy(content) {
copyToClipboard(content); return copyToClipboard(content);
} }
}; };
}; };
export const copyToClipboard = async (content) => { export const copyToClipboard = async (content) => {
const txtEl = document.createElement('input');
txtEl.type = 'hidden';
document.body.appendChild(txtEl);
txtEl.value = content;
try { try {
await navigator.clipboard.writeText(content); await navigator.clipboard.writeText(content);
return true; return true;
} catch (err) { } catch (err) {
return false; return false;
} finally {
document.body.removeChild(txtEl);
} }
} }