-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Support for logical not ! operator in binding to boolean values #7630
Comments
I'd second the issues linked by @Prinzhorn too. Svelte only supports binding to variables, not expressions. |
I suggest not using the Hence your example with an equality check becomes: <Toggle bind:checked={$isChecked}>Label</Toggle>
<Toggle bind:checked={$isChecked === false}>Label</Toggle> |
Since this issue is about supporting binding with <Toggle bind:checked={!$unChecked}>Label</Toggle> and this is not going to happen. So I am going to close this issue. What is more likely to happen would be <Toggle bind:checked|negated={$unChecked}>Label</Toggle> as @Prinzhorn mentioned. So if you are interested on that, do check out the issue #3937 and #7265. |
I agree with @Prinzhorn that it could be done with an input modifier On the logical point of view, after |
Describe the problem
I'm trying to bind to a boolean value from a store, but I actually want the inverse boolean value to be bound
ie:
<Toggle bind:checked={!$unChecked}>Label</Toggle>
I get the error
Can only bind to an identifier (e.g. 'foo') ...
Describe the proposed solution
would be cool to support the ! syntax
<Toggle bind:checked={$isChecked}>Label</Toggle>
<Toggle bind:checked={!$unChecked}>Label</Toggle>
Alternatives considered
current workaround:
Importance
nice to have
The text was updated successfully, but these errors were encountered: