diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-15 18:54:01 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-15 18:54:22 -0400 |
commit | 0bf5694063669734475b39eae393e3c3ee364fbe (patch) | |
tree | 0148294c3826ee89e5038d6f8a221dc8bd9c70be /src/util | |
parent | d2eeb0c79fdb891b8489d3d0d6f6656e0e26cc4a (diff) |
html: disallow content for imaginary-sibling
That means it's a throw, instead of silently dropping the content, when you pass it through html.metatag('imaginary-sibling').
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/html.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util/html.js b/src/util/html.js index a21d373f..85464b72 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -329,7 +329,7 @@ export function metatag(identifier, ...args) { return new Tag(null, {[chunkwrap]: true, ...opts}, content); case 'imaginary-sibling': - return new Tag(null, {[imaginarySibling]: true}); + return new Tag(null, {[imaginarySibling]: true}, content); default: throw new Error(`Unknown metatag "${identifier}"`); @@ -413,6 +413,10 @@ export class Tag { throw new Error(`Tag <${this.tagName}> is self-closing but got content`); } + if (this.imaginarySibling && contentful) { + throw new Error(`html.metatag('imaginary-sibling') can't have content`); + } + const contentArray = (Array.isArray(value) ? value.flat(Infinity).filter(Boolean) @@ -572,6 +576,12 @@ export class Tag { set imaginarySibling(value) { this.#setAttributeFlag(imaginarySibling, value); + + try { + this.content = this.content; + } catch (error) { + this.#setAttributeFlag(imaginarySibling, false); + } } get imaginarySibling() { |