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

fn helper does not partially apply arguments #17959

Closed
kovalchik opened this issue Apr 23, 2019 · 2 comments · Fixed by #17961
Closed

fn helper does not partially apply arguments #17959

kovalchik opened this issue Apr 23, 2019 · 2 comments · Fixed by #17961
Assignees

Comments

@kovalchik
Copy link

I’ve noticed that the new fn helper does partially apply the arguments of combined fn calls. I’ve set up a sandbox to demonstrate (be sure to open your browser console): https://codesandbox.io/s/wnkp6m7mww (It’s worth noting that the ember-on-modifier modifier addon is not working with this sandbox (unsure why), so I'm falling back to an onclick handler). I expected the handler to recieve arguments of both fn calls, similar to how the action handle applys arguments. Instead the second argument is undefined.

The RFC was not updated to explicitly cover this use case and states that fn is essentially just essentially calling this.passedMethod.call(…arguments);, which wouldn’t necessarily result in the argument application behavior that the action helper provides. It's possible that this is the intended functionality, however, after some Discord discussion, it seems that this may be a bug that warrants some investigation.


Here's a sandbox with a more realistic example (again, be sure to open your console): https://codesandbox.io/s/2x9wyyqjxj I’ve intentionally left the Stars component very generic. That is, I’m not passing a movie ID in as a component argument; this component could be used for rating something other than movies. Using the action helper, the consumer can pass down an action with additional arguments (the movie id) and the Stars component can utilize that action and pass along its own arguments. The fn helper does not function in the same way, and the second argument in the handleRatingUpdate action handler results in undefined.

@rwjblue
Copy link
Member

rwjblue commented Apr 23, 2019

Thanks for reporting! Definitely a bug, I'll also PR an update to the RFC prose to clarify the intent as well.

@kovalchik
Copy link
Author

Thanks for the fix! Works after testing! 🙌

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

Successfully merging a pull request may close this issue.

2 participants