Skip to content

Commit

Permalink
fix(router): migration incorrectly replacing deprecated key (#39763)
Browse files Browse the repository at this point in the history
In #38762 we added a migration to replace the deprecated `preserveQueryParams`
option with `queryParamsHandling`, however due to a typo, we ended up replacing it
with `queryParamsHandler` which is invalid.

Fixes #39755.

PR Close #39763
  • Loading branch information
crisbeto authored and AndrewKushnir committed Nov 19, 2020
1 parent 04e469e commit 0237845
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/core/schematics/migrations.json
Expand Up @@ -72,7 +72,7 @@
},
"migration-v11-router-preserve-query-params": {
"version": "11.0.0-beta",
"description": "NavigationExtras.preserveQueryParams has been removed as of Angular version 11. This migration replaces any usages with the appropriate assignment of the queryParamsHandler key.",
"description": "NavigationExtras.preserveQueryParams has been removed as of Angular version 11. This migration replaces any usages with the appropriate assignment of the queryParamsHandling key.",
"factory": "./migrations/router-preserve-query-params/index"
},
"migration-v11-router-initial-navigation-options": {
Expand Down
Expand Up @@ -2,7 +2,7 @@

Previously the `NatigationExtras` property of `preserveQueryParams` defined what should be done with
query parameters on navigation. This migration updates the usages of `preserveQueryParams` to
instead use the `queryParamsHandler` property.
instead use the `queryParamsHandling` property.

#### Before
```ts
Expand All @@ -29,7 +29,7 @@ export class MyComponent {
constructor(private _router: Router) {}

goHome() {
this._router.navigate('/', { queryParamsHandler: 'preserve', skipLocationChange: 'foo' });
this._router.navigate('/', { queryParamsHandling: 'preserve', skipLocationChange: 'foo' });
}
}
```
Expand Up @@ -56,7 +56,7 @@ export function migrateLiteral(
return ts.updateObjectLiteral(
node,
propertiesToKeep.concat(
ts.createPropertyAssignment('queryParamsHandler', ts.createIdentifier(`'preserve'`))));
ts.createPropertyAssignment('queryParamsHandling', ts.createIdentifier(`'preserve'`))));
}

return ts.updateObjectLiteral(node, propertiesToKeep);
Expand Down
Expand Up @@ -71,7 +71,7 @@ describe('NavigationExtras preserveQueryParams migration', () => {
await runMigration();

const content = tree.readContent('/index.ts');
expect(content).toContain(`this._router.navigate('/', { queryParamsHandler: 'preserve' });`);
expect(content).toContain(`this._router.navigate('/', { queryParamsHandling: 'preserve' });`);
});

it('`createUrlTree` function', async () => {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('NavigationExtras preserveQueryParams migration', () => {

const content = tree.readContent('/index.ts');
expect(content).toContain(
`const config = { replaceUrl: true, fragment: 'foo', state: {}, queryParamsHandler: 'preserve' };`);
`const config = { replaceUrl: true, fragment: 'foo', state: {}, queryParamsHandling: 'preserve' };`);
});

it('should remove when the value is `false`', async () => {
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('NavigationExtras preserveQueryParams migration', () => {

const content = tree.readContent('/index.ts');
expect(content).toContain(
`this._router.navigate('/', { replaceUrl: true, fragment: 'foo', state: {}, queryParamsHandler: 'preserve' });`);
`this._router.navigate('/', { replaceUrl: true, fragment: 'foo', state: {}, queryParamsHandling: 'preserve' });`);
});

it('should remove when the value is `false`', async () => {
Expand Down

0 comments on commit 0237845

Please sign in to comment.