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

animated-value with undefined value and key throws error #14

Open
nickschot opened this issue Mar 4, 2018 · 3 comments
Open

animated-value with undefined value and key throws error #14

nickschot opened this issue Mar 4, 2018 · 3 comments
Assignees
Labels

Comments

@nickschot
Copy link
Contributor

nickschot commented Mar 4, 2018

When using ember-elsewhere you might not always want to provide a defined value (e.g. a page where nothing should be rendered in the elsewhere). Currently when passing an undefined value to an animated-value and at the same time providing a key attribute throws a Assertion Failed: Cannot call get with 'text' on an undefined object.

Seems to be originating from https://github.com/ember-animation/ember-animated/blob/master/addon/components/animated-each.js#L88

@ef4
Copy link
Contributor

ef4 commented Mar 4, 2018

Ah, make sense. I think we would fix this in animated-value. Currently it essentially passes items=[value] to animated-each, but when value is null we should pass items=[].

@ef4
Copy link
Contributor

ef4 commented Mar 14, 2018

My apologies, but now that I think more about it, I was wrong in my comment above.

null is a valid value that you may want to render and animate.

For example:

{{#animated-value myPreference as |pref|}}
  {{#if pref}}
      Your preference is {{pref}}.
   {{else}}
      You have not chosen a preference.
   {{/if}}
{{/animated-value}}

While it would be possible to make animated-value accept its own {{else}} block, that's a complication I would rather avoid, when you can achieve the same thing as above without learning a new concept.

So instead I think we should add guards where we try to use the key property to access properties on the possibly-null value.

@Cryrivers
Copy link
Collaborator

@ef4 sure, i will investigate this weekend.

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

No branches or pull requests

3 participants