From 98c3d2e96df25f61fab3800e426613d6a2eea39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 5 Sep 2023 13:42:34 -0400 Subject: [PATCH] refactor: use map/get --- public/src/client/topic.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/src/client/topic.js b/public/src/client/topic.js index a04807f36c..cf456a1271 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -225,10 +225,8 @@ define('forum/topic', [ setTimeout(() => btn.find('i').removeClass('fa-check').addClass('fa-copy'), 2000); const codeEl = btn.parent().find('code'); if (codeEl.attr('data-lines')) { - let codeText = ''; - codeEl.find('.hljs-ln-code[data-line-number]') - .each((index, el) => { codeText += $(el).text() + '\n'; }); - return codeText; + return codeEl.find('.hljs-ln-code[data-line-number]') + .map((i, e) => e.textContent).get().join('\n'); } return codeEl.text(); },