diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-12 15:16:12 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-12 15:16:12 -0300 |
commit | 7fff96a6dbd3858281b040e5cf4d7d86843f43d6 (patch) | |
tree | e547e3d26c4e8a6fa5446a73b43bb0c567ee1a5f | |
parent | 6933e233d5470ed6631650ef850979deb924d9ab (diff) |
html: Tag.content: clean up contentArray compute
-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(); } |