offirgolan / ember-parachute

Improved Query Params for Ember
https://offirgolan.github.io/ember-parachute
MIT License
199 stars 40 forks source link

Unexpected values of queryParams on a controller using decorators #78

Closed jonopus closed 5 years ago

jonopus commented 5 years ago

I'm seeing unexpected values of queryParams on a controller using decorators.

Steps to reproduce:

  1. Add the following init method to tests/dummy/app/controllers/index.js.
    init(){
    this._super(...arguments);
    console.log(this.get('queryParams'));
    }
  2. Serve the app

    . Notice in the console that queryParams is an array of hashes rather than an array or a hash.

    [
    {"parachuteOpen":{"as":"parachute"}},
    {"parachuteOpen":{"as":"parachute"},"page":{"as":"page"}},
    {"parachuteOpen":{"as":"parachute"},"page":{"as":"page"},"search":{"as":"search"}},
    {"parachuteOpen":{"as":"parachute"},"page":{"as":"page"},"search":{"as":"search"},"tags":{"as":"tags"}}
    ]

I would have expected this value to be in one of the following formats: [ "parachuteOpen", "page", "search", "tags" ] {"parachuteOpen":{"as":"parachute"},"page":{"as":"page"},"search":{"as":"search"},"tags":{"as":"tags"}}

I believe this is cause when each decorator adds an additional init call. One possible solution might be to guard against calling init multiple times.