fix: don't throw with nullish actions (#13559)

Co-authored-by: Oscar Dominguez <dominguez.celada@gmail.com>
pull/14529/head
Paolo Ricciuti 9 months ago committed by GitHub
parent a5de086f95
commit 39275684e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: don't throw with nullish actions

@ -20,7 +20,10 @@ export function UseDirective(node, context) {
context.state.node,
b.arrow(
params,
b.call(/** @type {Expression} */ (context.visit(parse_directive_name(node.name))), ...params)
b.maybe_call(
/** @type {Expression} */ (context.visit(parse_directive_name(node.name))),
...params
)
)
];

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

@ -0,0 +1,7 @@
<script>
let { action_prop } = $props();
let action = $state();
</script>
<div use:action></div>
<div use:action_prop></div>
Loading…
Cancel
Save