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

[BUGFIX beta] fix passing array argument to action helper #11260

Merged
merged 1 commit into from
May 23, 2015

Conversation

csantero
Copy link
Contributor

Currently, given an action with at least one wrapped closure argument, calling that action with an array argument causes the elements of that array get flattened into individual arguments for the handler:

///app/components/inner-component.js
export default Ember.Component.extend({
  click() {
    this.sendAction('someAction', [3, 4, 5]);
  }
});
{{!-- app/templates/components/outer-component.hbs --}}

{{inner-component someAction=(action "foo" "bar")}}
///app/components/outer-component.js
export default Ember.Component.extend({
  actions: {
    foo(arg1, arg2, arg3, arg4) {
      // arg1 === "foo"
      // arg2 === 3
      // arg3 === 4
      // arg4 === 5
    }
  }
});

The foo handler should instead be receiving two arguments, "bar", and [3, 4, 5].

@rwjblue
Copy link
Member

rwjblue commented May 23, 2015

Good catch, thank you!

Also, I totally claim this mistake. I specifically recall saying "why don't you use spread arguments here". D'OH!

rwjblue added a commit that referenced this pull request May 23, 2015
[BUGFIX beta] fix passing array argument to action helper
@rwjblue rwjblue merged commit 84689f4 into emberjs:master May 23, 2015
@csantero csantero deleted the array-arg branch May 23, 2015 21:46
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 this pull request may close these issues.

2 participants