Skip to content

concatenated properties work different then in "normal" ember coffeescript #8

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

Open
hajee opened this issue Apr 7, 2013 · 4 comments

Comments

@hajee
Copy link

hajee commented Apr 7, 2013

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.
@ghempton
Copy link
Owner

ghempton commented Apr 7, 2013

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?

@hajee
Copy link
Author

hajee commented Apr 8, 2013

How would that work on an extended concatenation like:

this.get('first.second.third')

@ghempton
Copy link
Owner

ghempton commented Apr 8, 2013

@first?.second?.third if you wanted all the access to be soaked.

@hajee
Copy link
Author

hajee commented Apr 8, 2013

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

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

No branches or pull requests

2 participants