Skip to content
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

[Bug] if helper returns null instead of undefined #19409

Closed
Turbo87 opened this issue Feb 15, 2021 · 4 comments · Fixed by #19412
Closed

[Bug] if helper returns null instead of undefined #19409

Turbo87 opened this issue Feb 15, 2021 · 4 comments · Fixed by #19412
Milestone

Comments

@Turbo87
Copy link
Member

Turbo87 commented Feb 15, 2021

🐞 Describe the Bug

The else path of an inline if helper used to return undefined, but starting with v3.25 it now returns null, which can be problematic in components that check for the existence of an argument via this.args.foo !== undefined.

🔬 Minimal Reproduction

<SomeComponent @foo={{if this.bar "baz"}} />

😕 Actual Behavior

When bar is truthy then foo will be "bar", if not, then it will be null.

🤔 Expected Behavior

When bar is truthy then foo will be "bar", if not, then it will be undefined.

🌍 Environment

  • Ember: 3.25.1
@rwjblue
Copy link
Member

rwjblue commented Feb 15, 2021

This is a bit unfortunate to care about 🤔. We definitely can fix it, but I'm not sure that this is something that we had explicitly intended. 🤔

@rwjblue
Copy link
Member

rwjblue commented Feb 15, 2021

Oh, also, you can work around this by explicitly returning undefined in the else:

<SomeComponent @foo={{if this.bar "baz" undefined}} />

@Turbo87
Copy link
Member Author

Turbo87 commented Feb 15, 2021

This is a bit unfortunate to care about

maybe, but it looks like we're not the only ones who got bitten by this: https://discord.com/channels/480462759797063690/480462759797063692/809912104240545812

in our case about 900 tests are failing in the test suite due to this unintentional change 😅

I guess usually I would just do if (this.arg.foo) {...}, but since @foo can be a number in our case and that number is allowed to be zero we went for the this.arg.foo !== undefined check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants