Skip to content

Commit

Permalink
refactor: use map/get
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Sep 5, 2023
1 parent 6d27f77 commit 98c3d2e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions public/src/client/topic.js
Expand Up @@ -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();
},
Expand Down

0 comments on commit 98c3d2e

Please sign in to comment.