fix: add `?? ` to memoized function calls in strings

gh-12896
Rich Harris 2 years ago
parent 1f99935b99
commit 00a85182fa

@ -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: '<span></span>'
});

@ -0,0 +1,5 @@
<script lang="ts">
const identity = (x: any) => x;
</script>
<span>{identity(null)}{identity(undefined)}</span>
Loading…
Cancel
Save