Skip to content

nullish operator ?? doesnt work on JS-view context varaibles #564

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
Cube707 opened this issue Apr 17, 2025 · 2 comments
Closed

nullish operator ?? doesnt work on JS-view context varaibles #564

Cube707 opened this issue Apr 17, 2025 · 2 comments
Labels
bug Undesired behavior caused by this plugin

Comments

@Cube707
Copy link
Contributor

Cube707 commented Apr 17, 2025

this is not really a bug and more of a documentation / discussion.

Describe the Issue

all undefined variables will be initialized with the empty string when filling context of a JS-view field.

context[variable.contextName] = variable.metadataSignal.get() ?? '';

Steps to Reproduce

The following JS-view doesn't behave as expected. instead of returning empty for undefined properties, it will return the empty string.

~~~meta-bind-js-view
{fuzz} as var
---
return context.bound.var ?? "empty"
~~~

Further context

Not sure how this behavior guards against other issues I cant think of right now. In that case it should be better documented to avoid confusion.

@Cube707 Cube707 added the bug Undesired behavior caused by this plugin label Apr 17, 2025
@mProjectsCode
Copy link
Owner

Not sure why that's there. Might be a carryover from normal view fields, but it doesn't make much sense for JS view fields. I will probably change it to context[variable.contextName] = variable.metadataSignal.get(); for the next minor release.

@Cube707
Copy link
Contributor Author

Cube707 commented Apr 17, 2025

Not sure why that's there. Might be a carryover from normal view fields, but it doesn't make much sense for JS view fields. I will probably change it to context[variable.contextName] = variable.metadataSignal.get(); for the next minor release.

happy to hear that. looking forward to the fix.

I have way to many context.bound.var ? context.bound.var : 'default' in my vault 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behavior caused by this plugin
Projects
None yet
Development

No branches or pull requests

2 participants