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] Keep rest positional parameters when nesting contextual components if needed. #13764

Merged
merged 1 commit into from
Jul 21, 2016

Commits on Jul 21, 2016

  1. [BUGFIX beta] Keep rest positional parameters when nesting contextual

    components if needed.
    
    Steps to reproduce the bug before this patch:
    
    1. Create a component with rest positional param (like `link-to`).
    2. Create contextual component (`(component "link-to" "index")`).
    3. Render it (`{{component (component "link-to" "index")}}`).
    4. Realize the component did not receive `"index"` at all.
    
    What was causing it?
    ====================
    
    Because of how positional parameters work (both in components and contextual
    components), it is needed to treat them at each level and then merge them.
    Sadly, this was causing to overwrite the rest positional parameters because
    when no parameters are passed, the attribute get an empty array nonetheless.
    
    In the example above, assuming `LinkToComponent.positionalParams === 'params'`:
    
    1. Contextual component in `2` gets its positional parameters processed and
       receives the following named parameters `{ params: ['index'] }`.
    2. When rendering, the `{{component}}` processes its own parameters getting
       `{ params: [] }`. Then it merges in a `new EmptyObject()` these attributes
       on top of the ones in the contextual component. (See what I did there?
       I used the JS keyword `new` as an adjective! He he. Don't judge me, it is
       pretty late in here)
    
    Solving the issue
    =================
    
    This PR changes the implementation of `mergeInNewHash` to keep the original
    positional parameters if the new ones are empty and the positional parameter is
    of type rest.
    
    Fixes emberjs#13742
    Serabe committed Jul 21, 2016
    Configuration menu
    Copy the full SHA
    7737eb4 View commit details
    Browse the repository at this point in the history