Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shiny-pots-render.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/meta": patch
---

Render nullish children as an empty tag during SSR instead of the literal string `"undefined"`. `escape` passes non-string values through untouched, so `<Title>{value?.title}</Title>` emitted `<title>undefined</title>` when `value` had not resolved yet.
7 changes: 5 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,15 @@ function renderTags(tags: Array<TagDescription>) {
)
.join("");

const children = flattenChildren(tag.props.children);
// nullish children would otherwise be interpolated into the tag as the
// literal string "undefined" / "null", since `escape` passes non-strings
// through untouched
const children = flattenChildren(tag.props.children) ?? "";

if (tag.setting?.close) {
return `<${tag.tag} data-sm="${tag.id}"${props}>${
// @ts-expect-error
tag.setting?.escape ? escape(children) : children || ""
tag.setting?.escape ? escape(children) : children
}</${tag.tag}>`;
}
return `<${tag.tag} data-sm="${tag.id}"${props}/>`;
Expand Down
Loading