From 0bf5694063669734475b39eae393e3c3ee364fbe Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 15 Nov 2024 18:54:01 -0400 Subject: 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'). --- src/util/html.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/util') 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() { -- cgit 1.3.0-6-gf8a5