fix(router): remove preserveQueryParams symbol (#38762)

Remove preserveQueryParams as it was deprecated for removal in v4, use
queryParamsHandling="preserve" instead.

BREAKING CHANGE: preserveQueryParams has been removed, use
queryParamsHandling="preserve" instead

PR Close #38762
This commit is contained in:
Joey Perrott 2020-09-09 09:53:06 -07:00 committed by atscott
parent c6350116b5
commit 783a5bd7bb
5 changed files with 14 additions and 70 deletions

View File

@ -43,7 +43,6 @@ v9 - v12
| `@angular/core` | [`RenderComponentType`](#core) | <!--v7--> 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 |
@ -113,12 +112,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/UrlCreationOptions#preserveQueryParams) | [`queryParamsHandling`](api/router/UrlCreationOptions#queryParamsHandling) | v4 | none |
{@a upgrade}
### @angular/upgrade

View File

@ -341,7 +341,7 @@ export declare class Router {
urlHandlingStrategy: UrlHandlingStrategy;
urlUpdateStrategy: 'deferred' | 'eager';
constructor(rootComponentType: Type<any> | null, urlSerializer: UrlSerializer, rootContexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Routes);
createUrlTree(commands: any[], navigationExtras?: UrlCreationOptions): UrlTree;
createUrlTree(commands: any[], navigationExtras?: NavigationExtras): UrlTree;
dispose(): void;
getCurrentNavigation(): Navigation | null;
initialNavigation(): void;
@ -378,7 +378,6 @@ export declare class RouterEvent {
export declare class RouterLink implements OnChanges {
fragment?: string;
preserveFragment: boolean;
/** @deprecated */ set preserveQueryParams(value: boolean);
queryParams?: Params | null;
queryParamsHandling?: QueryParamsHandling | null;
replaceUrl: boolean;
@ -411,7 +410,6 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
fragment?: string;
href: string;
preserveFragment: boolean;
/** @deprecated */ set preserveQueryParams(value: boolean);
queryParams?: Params | null;
queryParamsHandling?: QueryParamsHandling | null;
replaceUrl: boolean;
@ -498,7 +496,6 @@ export declare class Scroll {
export declare interface UrlCreationOptions {
fragment?: string;
preserveFragment?: boolean;
/** @deprecated */ preserveQueryParams?: boolean;
queryParams?: Params | null;
queryParamsHandling?: QueryParamsHandling | null;
relativeTo?: ActivatedRoute | null;

View File

@ -206,17 +206,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 {
@ -234,7 +223,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),
});
@ -346,17 +334,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();
@ -399,7 +376,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),
});

View File

@ -104,14 +104,6 @@ export interface UrlCreationOptions {
*/
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:
@ -1104,35 +1096,21 @@ export class Router {
* router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
* ```
*/
createUrlTree(commands: any[], navigationExtras: UrlCreationOptions = {}): 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.');
}
createUrlTree(commands: any[], navigationExtras: NavigationExtras = {}): UrlTree {
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);

View File

@ -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 {
}