Skip to content

Commit 0237845

Browse files
crisbetoAndrewKushnir
authored andcommitted
fix(router): migration incorrectly replacing deprecated key (#39763)
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
1 parent 04e469e commit 0237845

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/core/schematics/migrations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
"migration-v11-router-preserve-query-params": {
7474
"version": "11.0.0-beta",
75-
"description": "NavigationExtras.preserveQueryParams has been removed as of Angular version 11. This migration replaces any usages with the appropriate assignment of the queryParamsHandler key.",
75+
"description": "NavigationExtras.preserveQueryParams has been removed as of Angular version 11. This migration replaces any usages with the appropriate assignment of the queryParamsHandling key.",
7676
"factory": "./migrations/router-preserve-query-params/index"
7777
},
7878
"migration-v11-router-initial-navigation-options": {

packages/core/schematics/migrations/router-preserve-query-params/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
#### Before
88
```ts
@@ -29,7 +29,7 @@ export class MyComponent {
2929
constructor(private _router: Router) {}
3030

3131
goHome() {
32-
this._router.navigate('/', { queryParamsHandler: 'preserve', skipLocationChange: 'foo' });
32+
this._router.navigate('/', { queryParamsHandling: 'preserve', skipLocationChange: 'foo' });
3333
}
3434
}
3535
```

packages/core/schematics/migrations/router-preserve-query-params/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function migrateLiteral(
5656
return ts.updateObjectLiteral(
5757
node,
5858
propertiesToKeep.concat(
59-
ts.createPropertyAssignment('queryParamsHandler', ts.createIdentifier(`'preserve'`))));
59+
ts.createPropertyAssignment('queryParamsHandling', ts.createIdentifier(`'preserve'`))));
6060
}
6161

6262
return ts.updateObjectLiteral(node, propertiesToKeep);

packages/core/schematics/test/preserve_query_params_migration_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('NavigationExtras preserveQueryParams migration', () => {
7171
await runMigration();
7272

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

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

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

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy