From 878655340c891abef6081ec93d3f53e72e0aebc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=ADguel=20=C3=81ngel=20Mulero=20Mart=C3=ADnez?= Date: Thu, 11 Apr 2024 19:59:12 +0200 Subject: [PATCH] Make the code simpler using modern js Co-authored-by: Tomas Chmelevskij --- src/js/Clipboard.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/js/Clipboard.js b/src/js/Clipboard.js index 6c36da742d..5a2c551000 100644 --- a/src/js/Clipboard.js +++ b/src/js/Clipboard.js @@ -87,30 +87,16 @@ Clipboard._configureClipboardAsWeb = function() { this.writeText = function(text, onSuccess, onError) { navigator.clipboard.writeText(text).then( - function() { - if (onSuccess) { - onSuccess(text); - } - }, function(err) { - if (onError) { - onError(err); - } - }, + () => onSuccess?.(text), + onError, ); }; this.readText = function(onSuccess, onError) { navigator.clipboard.readText().then( - function(text) { - if (onSuccess) { - onSuccess(text); - } - }, function(err) { - if (onError) { - onError(err); - } - }, + () => onSuccess?.(text), + onError, ); }; };