fix: ensure nullish expressions render empty text (#12898)

pull/12897/head
Dominic Gannaway 1 month ago committed by GitHub
parent 1f99935b99
commit aa5c4421cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure nullish expressions render empty text

@ -59,7 +59,13 @@ export function build_template_literal(values, visit, state) {
id,
create_derived(
state,
b.thunk(/** @type {Expression} */ (visit(node.expression, state)))
b.thunk(
b.logical(
'??',
/** @type {Expression} */ (visit(node.expression, state)),
b.literal('')
)
)
)
)
);

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: '<li></li>'
});

@ -0,0 +1,4 @@
<script>
function fn() {}
</script>
<li>{fn()}{null && fn()}</li>
Loading…
Cancel
Save