Skip to content

Allow nullish actions #13555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kwangure opened this issue Oct 10, 2024 · 4 comments · Fixed by #13559
Closed

Allow nullish actions #13555

kwangure opened this issue Oct 10, 2024 · 4 comments · Fixed by #13559

Comments

@kwangure
Copy link
Contributor

Describe the problem

I'm frustrated when I have to use a noop action, as a placeholder while Svelte accepts nullish values in other places in the template.

Describe the proposed solution

Do not error when nullish actions are used.

<script>
	const foo = undefined;
</script>

<button onclick={foo}>foo</button>
<button class:foo>bar</button>
<!-- Error: foo is not a function  -->
<button use:foo>bar</button>

Importance

would make my life easier

@Prinzhorn
Copy link
Contributor

AFAIK actions are not reactive at all right now, so even if nullish was supported, you couldn't swap it with an actual implementation later:

#6754
#6942

@kwangure
Copy link
Contributor Author

This is helpful if you're passing nullable actions as props.

@Prinzhorn
Copy link
Contributor

This is helpful if you're passing nullable actions as props.

I didn't say it wasn't helpful. But actions cannot be swapped out right now (see linked issues). So if your prop changes to non-nullish later, it won't update.

@adiguba adiguba mentioned this issue Oct 26, 2024
5 tasks
@dummdidumm
Copy link
Member

Closing in favor of #6942

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants