Skip to content

Commit 3927568

Browse files
fix: don't throw with nullish actions (#13559)
Co-authored-by: Oscar Dominguez <[email protected]>
1 parent a5de086 commit 3927568

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

.changeset/afraid-worms-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: don't throw with nullish actions

packages/svelte/src/compiler/phases/3-transform/client/visitors/UseDirective.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export function UseDirective(node, context) {
2020
context.state.node,
2121
b.arrow(
2222
params,
23-
b.call(/** @type {Expression} */ (context.visit(parse_directive_name(node.name))), ...params)
23+
b.maybe_call(
24+
/** @type {Expression} */ (context.visit(parse_directive_name(node.name))),
25+
...params
26+
)
2427
)
2528
];
2629

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: '<div></div> <div></div>'
5+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
let { action_prop } = $props();
3+
let action = $state();
4+
</script>
5+
6+
<div use:action></div>
7+
<div use:action_prop></div>

0 commit comments

Comments
 (0)