Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: emberjs/ember.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.28.0
Choose a base ref
...
head repository: emberjs/ember.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.28.1
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Aug 30, 2021

  1. [BUGFIX release] fix router test regression in urlFor and recognize

    As part of the improvements made between 3.24 and 3.28, the router
    microlib is now lazily loaded. When these changes were made, there were
    a couple cases where it *should* be possible to access router state in
    a non-application test (integration etc.) but it currently is not
    because the router is not necessarily set up. Since `setupRouter` is
    idempotent, call it in those functions so that if it is *not* set up,
    it gets set up, and otherwise it will continue working as expected.
    
    (cherry picked from commit 9f61c7a)
    chriskrycho authored and rwjblue committed Aug 30, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4e097e6 View commit details
  2. Add v3.28.1 to CHANGELOG.md.

    rwjblue committed Aug 30, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c37df4d View commit details
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Ember Changelog

## v3.28.1 (August 30, 2021)

- [#19733](https://github.com/emberjs/ember.js/pull/19733) [BUGFIX] Ensure that using `routerService.urlFor(...)` and `routerService.recognize(...)` does not error if the router is not fully initialized

## v3.28.0 (August 9, 2021)

- [#19697](https://github.com/emberjs/ember.js/pull/19697) [BUGFIX] Ensure `deserializeQueryParam` is called for lazy routes
3 changes: 3 additions & 0 deletions packages/@ember/-internals/routing/lib/services/router.ts
Original file line number Diff line number Diff line change
@@ -240,6 +240,7 @@ export default class RouterService extends Service {
@public
*/
urlFor(routeName: string, ...args: any[]) {
this._router.setupRouter();
return this._router.generate(routeName, ...args);
}

@@ -375,6 +376,7 @@ export default class RouterService extends Service {
`You must pass a url that begins with the application's rootURL "${this.rootURL}"`,
url.indexOf(this.rootURL) === 0
);
this._router.setupRouter();
let internalURL = cleanURL(url, this.rootURL);
return this._router._routerMicrolib.recognize(internalURL);
}
@@ -395,6 +397,7 @@ export default class RouterService extends Service {
`You must pass a url that begins with the application's rootURL "${this.rootURL}"`,
url.indexOf(this.rootURL) === 0
);
this._router.setupRouter();
let internalURL = cleanURL(url, this.rootURL);
return this._router._routerMicrolib.recognizeAndLoad(internalURL);
}
Original file line number Diff line number Diff line change
@@ -66,14 +66,15 @@ moduleFor(
}

['@test RouterService#urlFor returns url'](assert) {
let router = this.owner.lookup('router:main');
router.setupRouter();
assert.equal(this.routerService.urlFor('parent.child'), '/child');
}

['@test RouterService#transitionTo with basic route'](assert) {
assert.expect(2);

// Callers who want to actually execute a transition in a non-application
// test are doing something weird and therefore should do
// `owner.setupRouter()` explicitly in their tests.
let componentInstance;
let router = this.owner.lookup('router:main');
router.setupRouter();
@@ -107,8 +108,6 @@ moduleFor(
}

['@test RouterService#recognize recognize returns routeInfo'](assert) {
let router = this.owner.lookup('router:main');
router.setupRouter();
let routeInfo = this.routerService.recognize('/dynamic-with-child/123/1?a=b');
assert.ok(routeInfo);
let { name, localName, parent, child, params, queryParams, paramNames } = routeInfo;