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

Capitalized properties do not work with #if helper #3436

Closed
glennsl opened this issue Sep 17, 2013 · 5 comments
Closed

Capitalized properties do not work with #if helper #3436

glennsl opened this issue Sep 17, 2013 · 5 comments
Labels

Comments

@glennsl
Copy link

glennsl commented Sep 17, 2013

When using the #if helper with capitalized properties, the binding it sets up assumes the path is global, resulting in a broken binding.

E.g.:

{{#if view.SubView}}
    ...
{{/if}}

See the JSFiddle http://jsfiddle.net/NnKAN/. When "Destroy view" is clicked, it will break when it tries to unwatch the non-existing global path.

A workaround is obviously to not use capitalized properties, but it is a convention that comes very naturally for locally defined classes since class names are conventionally capitalized. Analogous to the Java/C#-style idiom:

class SomeClass {
    private class MyClass { }
}

And while {{#if MyView}} seems like it should be interpreted as a global path (according to Ember conventions), it is not very intuitive that {{#if view.MyView}} is interpreted as global, ignoring the "view." part of the path entirely.

I've also used this convention for some time now, without issue until this.

@wagenet
Copy link
Member

wagenet commented Nov 9, 2013

This certainly seems like a bug.

@stefanpenner
Copy link
Member

@wagenet it has todo with capital letters triggering a "global" lookup.

@wagenet
Copy link
Member

wagenet commented Nov 9, 2013

@stefanpenner yeah, that's what I figured. This should only happen if the path chain begins with a capital letter though.

@glennsl
Copy link
Author

glennsl commented Nov 10, 2013

@wagenet The problem is that the "view." part of the path is discarded because the path should be bound in the context of "view", rather than "this".

@wagenet
Copy link
Member

wagenet commented Jul 28, 2014

Resolved by #4459.

@wagenet wagenet closed this as completed Jul 28, 2014
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