Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/blue-badgers-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: treat nullish expression as empty string
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function build_template_chunk(
// If we have a single expression, then pass that in directly to possibly avoid doing
// extra work in the template_effect (instead we do the work in set_text).
if (evaluated.is_known) {
value = b.literal(evaluated.value);
value = b.literal((evaluated.value ?? '') + '');
}

return { value, has_state };
Expand All @@ -96,7 +96,7 @@ export function build_template_chunk(
}

if (evaluated.is_known) {
quasi.value.cooked += evaluated.value + '';
quasi.value.cooked += (evaluated.value ?? '') + '';
} else {
if (!evaluated.is_defined) {
// add `?? ''` where necessary
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
html: '[]'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{undefined ?? null}]
Loading