Skip to content

Commit b96fc34

Browse files
authored
Fix HTML creator crediting incorrect image tags (#4653)
1 parent 2b5dc83 commit b96fc34

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

frontend/src/utils/attribution-html.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,31 @@ const h = (
4646
attrs: Record<string, string>,
4747
children: string[] | null = null
4848
): string => {
49+
const selfClosingTags = [
50+
"area",
51+
"base",
52+
"br",
53+
"col",
54+
"embed",
55+
"hr",
56+
"img",
57+
"input",
58+
"link",
59+
"meta",
60+
"param",
61+
"source",
62+
"track",
63+
"wbr",
64+
]
65+
4966
const map = Object.entries(attrs)
5067
.map(([key, value]) => `${key}="${value}"`)
5168
.join(" ")
69+
70+
if (selfClosingTags.includes(name)) {
71+
return map ? `<${name} ${map} />` : `<${name} />`
72+
}
73+
5274
const opening = map ? `<${name} ${map}>` : `<${name}>`
5375
const closing = `</${name}>`
5476
return `${opening}${(children ?? []).join("\n")}${closing}`

0 commit comments

Comments
 (0)