From f0013d8fd937f2f1d14608edb7bb36d4c7f7e85c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Dec 2023 18:39:08 -0400 Subject: html: refactor #stringifyContent --- src/util/html.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/util') diff --git a/src/util/html.js b/src/util/html.js index f13f8c29..4be008ed 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -397,14 +397,27 @@ export class Tag { const joiner = (this.joinChildren === undefined ? '\n' - : (this.joinChildren === '' - ? '' - : `\n${this.joinChildren}\n`)); - - return this.content - .map(item => item.toString()) - .filter(Boolean) - .join(joiner); + : this.joinChildren === '' + ? '' + : `\n${this.joinChildren}\n`); + + let content = ''; + + for (const [index, item] of this.content.entries()) { + const itemContent = item.toString(); + + if (!itemContent) { + continue; + } + + if (content) { + content += joiner; + } + + content += itemContent; + } + + return content; } static normalize(content) { -- cgit 1.3.0-6-gf8a5