diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-15 18:52:50 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-15 18:52:50 -0400 |
commit | d2eeb0c79fdb891b8489d3d0d6f6656e0e26cc4a (patch) | |
tree | c73a34d3c18ffe7ce7de57cfb74041c18d16116f /src/util/html.js | |
parent | 9e9ad40859181e40857818b2c72d97b752ee7f27 (diff) |
html: factor out contentful conditions in content setter
So not really factored out much at all, but eh.
Diffstat (limited to 'src/util/html.js')
-rw-r--r-- | src/util/html.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/util/html.js b/src/util/html.js index 35703d4a..a21d373f 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -401,13 +401,15 @@ export class Tag { } set content(value) { - if ( - this.selfClosing && - !(value === null || - value === undefined || - !value || - Array.isArray(value) && value.filter(Boolean).length === 0) - ) { + const contentful = + value !== null && + value !== undefined && + value && + (Array.isArray(value) + ? !empty(value.filter(Boolean)) + : true); + + if (this.selfClosing && contentful) { throw new Error(`Tag <${this.tagName}> is self-closing but got content`); } |