Skip to content

Commit

Permalink
fix(router): remove preserveQueryParams symbol
Browse files Browse the repository at this point in the history
Remove preserveQueryParams as it was deprecated for removal in v4, use
queryParamsHandling="preserve" instead.

BREAKING CHANGE: preserveQueryParams has been removed, use
queryParamsHandling="preserve" instead
  • Loading branch information
josephperrott committed Sep 10, 2020
1 parent 26f2820 commit 8ac7f8f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 69 deletions.
8 changes: 0 additions & 8 deletions aio/content/guide/deprecations.md
Expand Up @@ -44,7 +44,6 @@ v9 - v12
| `@angular/core` | [`ViewEncapsulation.Native`](#core) | <!--v6--> v11 |
| `@angular/core` | [`WrappedValue`](#core) | <!--v10--> v12 |
| `@angular/forms` | [`ngModel` with reactive forms](#ngmodel-reactive) | <!--v6--> v11 |
| `@angular/router` | [`preserveQueryParams`](#router) | <!--v7--> v11 |
| `@angular/upgrade` | [`@angular/upgrade`](#upgrade) | <!--v8--> v11 |
| `@angular/upgrade` | [`getAngularLib`](#upgrade-static) | <!--v8--> v11 |
| `@angular/upgrade` | [`setAngularLib`](#upgrade-static) | <!--v8--> v11 |
Expand Down Expand Up @@ -117,13 +116,6 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
| --- | ----------- | --------------------- | ----- |
| [`ngModel` with reactive forms](#ngmodel-reactive) | [`FormControlDirective`](api/forms/FormControlDirective) | v6 | none |

{@a router}
### @angular/router

| API | Replacement | Deprecation announced | Notes |
| --- | ----------- | --------------------- | ----- |
| [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#queryParamsHandling) | v4 | none |

{@a platform-webworker}
### @angular/platform-webworker

Expand Down
3 changes: 0 additions & 3 deletions goldens/public-api/router/router.d.ts
Expand Up @@ -202,7 +202,6 @@ export declare class NavigationError extends RouterEvent {
export declare interface NavigationExtras {
fragment?: string;
preserveFragment?: boolean;
/** @deprecated */ preserveQueryParams?: boolean;
queryParams?: Params | null;
queryParamsHandling?: QueryParamsHandling | null;
relativeTo?: ActivatedRoute | null;
Expand Down Expand Up @@ -381,7 +380,6 @@ export declare class RouterEvent {
export declare class RouterLink implements OnChanges {
fragment: string;
preserveFragment: boolean;
/** @deprecated */ set preserveQueryParams(value: boolean);
queryParams: {
[k: string]: any;
};
Expand Down Expand Up @@ -416,7 +414,6 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
fragment: string;
href: string;
preserveFragment: boolean;
/** @deprecated */ set preserveQueryParams(value: boolean);
queryParams: {
[k: string]: any;
};
Expand Down
24 changes: 0 additions & 24 deletions packages/router/src/directives/router_link.ts
Expand Up @@ -201,17 +201,6 @@ export class RouterLink implements OnChanges {
}
}

/**
* @deprecated As of Angular v4.0 use `queryParamsHandling` instead.
*/
@Input()
set preserveQueryParams(value: boolean) {
if ((typeof ngDevMode === 'undefined' || ngDevMode) && <any>console && <any>console.warn) {
console.warn('preserveQueryParams is deprecated!, use queryParamsHandling instead.');
}
this.preserve = value;
}

/** @nodoc */
@HostListener('click')
onClick(): boolean {
Expand All @@ -229,7 +218,6 @@ export class RouterLink implements OnChanges {
relativeTo: this.route,
queryParams: this.queryParams,
fragment: this.fragment,
preserveQueryParams: attrBoolValue(this.preserve),
queryParamsHandling: this.queryParamsHandling,
preserveFragment: attrBoolValue(this.preserveFragment),
});
Expand Down Expand Up @@ -337,17 +325,6 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
}
}

/**
* @deprecated As of Angular v4.0 use `queryParamsHandling` instead.
*/
@Input()
set preserveQueryParams(value: boolean) {
if ((typeof ngDevMode === 'undefined' || ngDevMode) && <any>console && <any>console.warn) {
console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
}
this.preserve = value;
}

/** @nodoc */
ngOnChanges(changes: SimpleChanges): any {
this.updateTargetUrlAndHref();
Expand Down Expand Up @@ -390,7 +367,6 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
relativeTo: this.route,
queryParams: this.queryParams,
fragment: this.fragment,
preserveQueryParams: attrBoolValue(this.preserve),
queryParamsHandling: this.queryParamsHandling,
preserveFragment: attrBoolValue(this.preserveFragment),
});
Expand Down
44 changes: 11 additions & 33 deletions packages/router/src/router.ts
Expand Up @@ -104,14 +104,6 @@ export interface NavigationExtras {
*/
fragment?: string;

/**
* **DEPRECATED**: Use `queryParamsHandling: "preserve"` instead to preserve
* query parameters for the next navigation.
*
* @deprecated since v4
*/
preserveQueryParams?: boolean;

/**
* How to handle query parameters in the router link for the next navigation.
* One of:
Expand Down Expand Up @@ -1069,34 +1061,20 @@ export class Router {
* ```
*/
createUrlTree(commands: any[], navigationExtras: NavigationExtras = {}): UrlTree {
const {
relativeTo,
queryParams,
fragment,
preserveQueryParams,
queryParamsHandling,
preserveFragment
} = navigationExtras;
if ((typeof ngDevMode === 'undefined' || ngDevMode) && preserveQueryParams && <any>console &&
<any>console.warn) {
console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
}
const {relativeTo, queryParams, fragment, queryParamsHandling, preserveFragment} =
navigationExtras;
const a = relativeTo || this.routerState.root;
const f = preserveFragment ? this.currentUrlTree.fragment : fragment;
let q: Params|null = null;
if (queryParamsHandling) {
switch (queryParamsHandling) {
case 'merge':
q = {...this.currentUrlTree.queryParams, ...queryParams};
break;
case 'preserve':
q = this.currentUrlTree.queryParams;
break;
default:
q = queryParams || null;
}
} else {
q = preserveQueryParams ? this.currentUrlTree.queryParams : queryParams || null;
switch (queryParamsHandling) {
case 'merge':
q = {...this.currentUrlTree.queryParams, ...queryParams};
break;
case 'preserve':
q = this.currentUrlTree.queryParams;
break;
default:
q = queryParams || null;
}
if (q !== null) {
q = this.removeEmptyProps(q);
Expand Down
2 changes: 1 addition & 1 deletion packages/router/test/integration.spec.ts
Expand Up @@ -2137,7 +2137,7 @@ describe('Integration', () => {
@Component({
selector: 'someRoot',
template:
`<router-outlet></router-outlet><a routerLink="/home" preserveQueryParams preserveFragment>Link</a>`
`<router-outlet></router-outlet><a routerLink="/home" queryParamsHandling="preserve" preserveFragment>Link</a>`
})
class RootCmpWithLink {
}
Expand Down

0 comments on commit 8ac7f8f

Please sign in to comment.