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

[Glimmer?] Helper does not receive correct view in 1.13 #11233

Closed
ghost opened this issue May 20, 2015 · 7 comments · Fixed by #11242
Closed

[Glimmer?] Helper does not receive correct view in 1.13 #11233

ghost opened this issue May 20, 2015 · 7 comments · Fixed by #11242
Milestone

Comments

@ghost
Copy link

ghost commented May 20, 2015

export default function(...props) {
  var options = props.pop();
  var view = options.data.view;

  // other code
}

In <= 1.12 view would be the component the helper would be called in.
In 1.13 this changed to the controllers view.

@mixonic
Copy link
Sponsor Member

mixonic commented May 20, 2015

@martndemus can you give us a more complete example? I think I know what you are saying, but I want to be sure.

@rwjblue
Copy link
Member

rwjblue commented May 20, 2015

Is this what you are talking about:

1.12 -> http://emberjs.jsbin.com/rwjblue/529/edit
canary -> http://emberjs.jsbin.com/rwjblue/528/edit


I am unsure what exactly options.data.view is when rendered inside of a yielding components template in 1.12, it is not the component or the application view (though I believe that the new behavior is more correct in that case).

@mixonic
Copy link
Sponsor Member

mixonic commented May 20, 2015

@martndemus I believe this may have indeed changed, but we're going to view this change as a bugfix.

Robert's demo doesn't show that the view passed to the helper was the component, however whatever it was, it was not the same as the {{view}} keyword would have been at the same place. For example:

{{#outer-component}}
  {{my-helper}} {{view.name}}
{{/outer-component}}

If my-helper reads view.name, it is reasonable to expect it is the same as {{view.name}} in the template. This is how Canary works, and it does this in a predictable way across many situations. Whatever the old view was, it was inappropriate for us to pass it to the helper.

If the old behavior was passing the component as the view, it was a violation of the "transparency" of the yielded block. This is the idea that when a component yields, everything in the yield goes back to the scope the component was called in.

@ghost
Copy link
Author

ghost commented May 20, 2015

Actually what I meant is this:
canary -> http://emberjs.jsbin.com/jugumevepo/2/edit?html,css,js,output

@rwjblue
Copy link
Member

rwjblue commented May 20, 2015

@martndemus - Great thank you for clarifying! Definitely seems like a bug to me.

@ghost
Copy link
Author

ghost commented May 20, 2015

No problem, hope it can get fixed soon!

@ghost
Copy link
Author

ghost commented May 21, 2015

You are awesome! 👍

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

Successfully merging a pull request may close this issue.

2 participants