emberjs / emberjs/ember.js

query params without controller declaration works when it shouldn't

Open
#18,238 0 comments 1 reaction 0 assignees View on GitHub
Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

Repro:

1. Set the following in the `index` route:

```js
// app/routes/index.js
queryParams: {
test: { refreshModel: true }
}
```

1. In a sibling route, access using `paramsFor`:

```js
// app/routes/foo.js
setupController() {
this.set('myQp', this.paramsFor('index').test);
}
```
1. Visit the app at `localhost:4200/foo?test=something`
1. See that the the `foo` template has `myQp` successfully set.

The issue is that query params have not officially been declared on any controller, so they're accessible everywhere? This is sort of unexpected behavior and I'm not sure what the "correct" behavior is, but it's worth investigating and possibly making more strict?

Here's a repro with Ember 3.11: https://github.com/mehulkar/ember-example-qp-no-declare

and the diff that has the chunk of what is described above: https://github.com/mehulkar/ember-example-qp-no-declare/commit/89240104e52bb7e388848ac55027b8acdaab4ba3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.