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

Ember 2.9.0 beta: Yielded value using with-helper in component block form breaks if null or undefined #14326

Closed
anssikin opened this issue Sep 21, 2016 · 4 comments

Comments

@anssikin
Copy link

Subject (and issue explanation) was slightly hard to come up with, sorry about that.

In short, the issue appears when yielding a value in component and referring to the value's property in the components block form in with-helper, if the given value is either null or undefined. This issue did not exist in Ember 2.8.1, so I'm assuming this has something to do with Glimmer 2. Here is a Ember Twiddle to demonstrate the issue: https://ember-twiddle.com/386db48506ac762153a3675bd6a39576/f4742940fc186cba83e70b5a235a7934ae84b379?openFiles=templates.application.hbs%2C . The issue can be seen via console, where a error should occur when switching Ember dependency to beta (and no error when switching to release).

As a practical use case, I'm using a async-render component which takes a promise as source property and internally uses a Ember.PromiseProxyMixin object, essentially rendering the content once the promise has resolved. If the promise had not resolved yet (the prop.isFulfilled was false), the component template would yield null. The with-helper was used to make reading the template a little easier. I acknowledge that this is potentially a design flaw on my part, but Ember 2.8.1 allowed this behavior, so a confirmation would be nice whether this is intended.

@Serabe
Copy link
Member

Serabe commented Sep 23, 2016

Thank you for your report!

@chancancode chancancode added this to the 2.10.0 milestone Oct 17, 2016
chancancode added a commit to glimmerjs/glimmer-vm that referenced this issue Nov 10, 2016
The previous `ValueReference` implementation does not handle edge cases
in its `get` method very well. For example, `new ValueReference(5).get("foo").get("bar")`
errors, causing bugs like emberjs/ember.js#14326.

Instead of trying to fix the general case, we made `PrimitiveReference`
public instead. This should cover the majority of the `ValueReference`
use cases, and the host could implement its own reference type for the
rest.
chancancode added a commit to glimmerjs/glimmer-vm that referenced this issue Nov 10, 2016
The previous `ValueReference` implementation does not handle edge cases
in its `get` method very well. For example, `new ValueReference(5).get("foo").get("bar")`
errors, causing bugs like emberjs/ember.js#14326.

Instead of trying to fix the general case, we made `PrimitiveReference`
public instead. This should cover the majority of the `ValueReference`
use cases, and the host could implement its own reference type for the
rest.
chancancode added a commit that referenced this issue Nov 10, 2016
chancancode added a commit that referenced this issue Nov 10, 2016
chancancode added a commit that referenced this issue Nov 10, 2016
rwjblue pushed a commit that referenced this issue Nov 10, 2016
chancancode added a commit that referenced this issue Nov 10, 2016
rwjblue pushed a commit that referenced this issue Nov 10, 2016
chancancode added a commit that referenced this issue Nov 27, 2016
Fixes #14326

(cherry picked from commit 8c19d96)
@foxnewsnetwork
Copy link

Currently on ember 2.10.0 and this bug seems to still be alive; consider the following twiddle:

https://ember-twiddle.com/18868df4738de43f6fdf99885dd53419?openFiles=templates.application.hbs%2C

Notably, the following handlebars snippet behaves incorrectly

{{#with false as |x|}}
  I should render, but I'm not {{x}}
{{/with}}

@Serabe
Copy link
Member

Serabe commented Dec 7, 2016

The problem in your twiddle is that you are using different version in "ember" than in "ember-template". If you match the version to 2.10 you will see no error.

Furthermore, that template should not render the text. As stated in the documentation:

If the aliased property is "falsey", for example: false, undefined null, "", 0, NaN or an empty array, the block will not be rendered.

Thank you!

@foxnewsnetwork
Copy link

Thanks @Serabe, I was unaware with doubles as an if block

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

No branches or pull requests

4 participants