ember-script
ember-script copied to clipboard
concatenated properties work different then in "normal" ember coffeescript
In 'normal' ember, when when the first property of a concatenated set of properties returns an 'undefined', the total get returns an 'undefined'.
@get('first.second')
When I use emberscript for this:
@first.second
it is compiled into:
return get$(get$(this, 'first'), 'second');
This raises an error
Cannot call get with 'second' on an undefined object.
So I am slightly torn on this one. My personal preference is to use the ?.
operator if you want soaked property access. What if instead the following:
@first?.second
Compiled into:
this.get('first.second')
Thoughts?
How would that work on an extended concatenation like:
this.get('first.second.third')
@first?.second?.third
if you wanted all the access to be soaked.
Have you considered always soaking unless you use the * operator? I haven't really looked into it, but ut seems Ember.set & Ember.get can handle this.
@first.second.third
would compile into:
get$(this, 'first.second.third')
and
@first*.second.third
would compile into:
this.first.get$(second, 'third')
and
@first*.second*.third
would compile into:
this.first.third