diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/html.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/util/html.js b/src/util/html.js index 6f75e57a..f340f9ef 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -373,13 +373,12 @@ export class Tag { throw new Error(`Tag <${this.tagName}> is self-closing but got content`); } - let contentArray; - - if (Array.isArray(value)) { - contentArray = value; - } else { - contentArray = [value]; - } + const contentArray = + (Array.isArray(value) + ? value.flat(Infinity).filter(Boolean) + : value + ? [value] + : []); if (this.chunkwrap) { if (contentArray.some(content => content?.blockwrap)) { @@ -387,10 +386,7 @@ export class Tag { } } - this.#content = contentArray - .flat(Infinity) - .filter(Boolean); - + this.#content = contentArray; this.#content.toString = () => this.#stringifyContent(); } |