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

[BREAKING BUGFIX] Fix positional params behavior to match Function#bind. #15287

Closed
wants to merge 1 commit into from

Commits on May 25, 2017

  1. [BREAKING BUGFIX] Fix positional params behavior to match Function#bind.

    In general, the concept of contextual components (which is what required
    the creation of `(component` helper) was meant to simulate "closing over"
    prior arguments.
    
    In the case of named arguments (aka "hash" arguments)
    the mechansim for that is fairly simple: merge all provided named arguments
    from each layer "upwards". This is what the majority of `(component` usages
    are relying on heavily today, and it works wonderfully!
    
    How exactly to handle positional arguments was a bit less obvious. The
    original implementation was to treat each layer as able to overwrite
    the prior layers positional arguments.
    
    For example, in this example the inner invocation (with `4 5 6` specified)
    would override the earlier passing of `1 2 3`:
    
    ```hbs
    {{#with (component 'x-foo' 1 2 3) as |comp|}}
      {{component comp 4 5 6}}
    {{/with}}
    ```
    
    For the most part, this behavior has not been an issue. Most likely this is
    due to the fact that `positionalParams` with components are used fairly
    rarely, and when they are folks haven't noticed/used this clobbering behavior.
    
    This commit changes the positional param behavior with contextual components
    to more closely match how `Function.prototype.bind` works (and more closely
    matches folks mental model of "closing over").
    
    After these changes the snippet above would result in invoking `x-foo`
    with `1 2 3 4 5 6`.
    
    As you can see, this now more closely resembles closing over the earlier
    values, and matches how the `action` helper handles positional parameters.
    
    Unfortunately, this bug fix is also a breaking change to folks that have
    been using contextual components that have `postionalParams` set and are
    utilizing the clobbering behavior.
    rwjblue committed May 25, 2017
    Configuration menu
    Copy the full SHA
    06abefd View commit details
    Browse the repository at this point in the history