Property chains raise an error when an intermediate value is undefined. #2301

Closed
ahawkins opened this Issue Mar 19, 2013 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

ahawkins commented Mar 19, 2013

I have a computed alias like this: Ember.computed.alias('sender.deals.firstObject'). Yes I know it's long and probably not as correct as it could be, but it gets the job done. This alias is defined on a controller. The controller manages /emails/:email_id. There is an error when switching between emails. I get a lovely error about "cannot call method split on undefined". This comes from the get method. Some method in the chain is returning undefined and breaking things. However this was basically impossible to track down which property was undefined and when. So I tried to trigger the error. I was able to trigger the error with these two code snippets:

App.EmailController = Ember.ObjectController.extend
  activeDeal: Ember.computed.alias('sender.deals.firstObject')
  sender: null # this stubs out the first value in the chain and raises the error
App.EmailController = Ember.ObjectController.extend
  # use fooBarBaz to illustrate a property that does not exist.
  activeDeal: Ember.computed.alias('sender.fooBarBazdeals.firstObject')

There are some other funny thing happening around this as well. The property chain observers generate chains that should not exist. The generated "content.undefined" in this case.

The question is: am I using these aliases correctly or should I create my own property and build in guards.

Owner

stefanpenner commented Mar 19, 2013

@twinturbo seems bad, can I assume you are on master?

Contributor

ahawkins commented Mar 19, 2013

c

On Mar 19, 2013, at 3:24 PM, Stefan Penner notifications@github.com wrote:

@twinturbo seems bad, can I assume you are on master?


Reply to this email directly or view it on GitHub.

Owner

stefanpenner commented Mar 19, 2013

just a friendly fiddle reminder.

Contributor

ahawkins commented Mar 21, 2013

@stefanpenner still working on figuring this out. I have a fiddle here that should demonstrate the issue, but it doesn't. I will keep trying: http://jsfiddle.net/twinturbo/XXMwS/1/.

Owner

stefanpenner commented Mar 21, 2013

@twinturbo thanks dude. If you can track it down that would be awesome. I'll see if i can lend a hand this weekend.

Owner

trek commented Jun 18, 2013

It doesn't seem this was reproducible. If we ever get a reproduction, let's revisit.

@trek trek closed this Jun 18, 2013

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