File tree Expand file tree Collapse file tree 4 files changed +13
-2
lines changed
src/compiler/phases/3-transform/client/visitors/shared
tests/runtime-runes/samples/nullish-empty-string Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' svelte ' : patch
3+ ---
4+
5+ fix: treat nullish expression as empty string
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ export function build_template_chunk(
7777 // If we have a single expression, then pass that in directly to possibly avoid doing
7878 // extra work in the template_effect (instead we do the work in set_text).
7979 if ( evaluated . is_known ) {
80- value = b . literal ( evaluated . value ) ;
80+ value = b . literal ( ( evaluated . value ?? '' ) + '' ) ;
8181 }
8282
8383 return { value, has_state } ;
@@ -96,7 +96,7 @@ export function build_template_chunk(
9696 }
9797
9898 if ( evaluated . is_known ) {
99- quasi . value . cooked += evaluated . value + '' ;
99+ quasi . value . cooked += ( evaluated . value ?? '' ) + '' ;
100100 } else {
101101 if ( ! evaluated . is_defined ) {
102102 // add `?? ''` where necessary
Original file line number Diff line number Diff line change 1+ import { test } from '../../test' ;
2+
3+ export default test ( {
4+ html : '[]'
5+ } ) ;
Original file line number Diff line number Diff line change 1+ [{undefined ?? null }]
You can’t perform that action at this time.
0 commit comments