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:
parent
c6350116b5
commit
783a5bd7bb
|
@ -43,7 +43,6 @@ v9 - v12
|
||||||
| `@angular/core` | [`RenderComponentType`](#core) | <!--v7--> v11 |
|
| `@angular/core` | [`RenderComponentType`](#core) | <!--v7--> v11 |
|
||||||
| `@angular/core` | [`WrappedValue`](#core) | <!--v10--> v12 |
|
| `@angular/core` | [`WrappedValue`](#core) | <!--v10--> v12 |
|
||||||
| `@angular/forms` | [`ngModel` with reactive forms](#ngmodel-reactive) | <!--v6--> v11 |
|
| `@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` | [`@angular/upgrade`](#upgrade) | <!--v8--> v11 |
|
||||||
| `@angular/upgrade` | [`getAngularLib`](#upgrade-static) | <!--v8--> v11 |
|
| `@angular/upgrade` | [`getAngularLib`](#upgrade-static) | <!--v8--> v11 |
|
||||||
| `@angular/upgrade` | [`setAngularLib`](#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 |
|
| [`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}
|
{@a upgrade}
|
||||||
### @angular/upgrade
|
### @angular/upgrade
|
||||||
|
|
|
@ -341,7 +341,7 @@ export declare class Router {
|
||||||
urlHandlingStrategy: UrlHandlingStrategy;
|
urlHandlingStrategy: UrlHandlingStrategy;
|
||||||
urlUpdateStrategy: 'deferred' | 'eager';
|
urlUpdateStrategy: 'deferred' | 'eager';
|
||||||
constructor(rootComponentType: Type<any> | null, urlSerializer: UrlSerializer, rootContexts: ChildrenOutletContexts, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Routes);
|
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;
|
dispose(): void;
|
||||||
getCurrentNavigation(): Navigation | null;
|
getCurrentNavigation(): Navigation | null;
|
||||||
initialNavigation(): void;
|
initialNavigation(): void;
|
||||||
|
@ -378,7 +378,6 @@ export declare class RouterEvent {
|
||||||
export declare class RouterLink implements OnChanges {
|
export declare class RouterLink implements OnChanges {
|
||||||
fragment?: string;
|
fragment?: string;
|
||||||
preserveFragment: boolean;
|
preserveFragment: boolean;
|
||||||
/** @deprecated */ set preserveQueryParams(value: boolean);
|
|
||||||
queryParams?: Params | null;
|
queryParams?: Params | null;
|
||||||
queryParamsHandling?: QueryParamsHandling | null;
|
queryParamsHandling?: QueryParamsHandling | null;
|
||||||
replaceUrl: boolean;
|
replaceUrl: boolean;
|
||||||
|
@ -411,7 +410,6 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
|
||||||
fragment?: string;
|
fragment?: string;
|
||||||
href: string;
|
href: string;
|
||||||
preserveFragment: boolean;
|
preserveFragment: boolean;
|
||||||
/** @deprecated */ set preserveQueryParams(value: boolean);
|
|
||||||
queryParams?: Params | null;
|
queryParams?: Params | null;
|
||||||
queryParamsHandling?: QueryParamsHandling | null;
|
queryParamsHandling?: QueryParamsHandling | null;
|
||||||
replaceUrl: boolean;
|
replaceUrl: boolean;
|
||||||
|
@ -498,7 +496,6 @@ export declare class Scroll {
|
||||||
export declare interface UrlCreationOptions {
|
export declare interface UrlCreationOptions {
|
||||||
fragment?: string;
|
fragment?: string;
|
||||||
preserveFragment?: boolean;
|
preserveFragment?: boolean;
|
||||||
/** @deprecated */ preserveQueryParams?: boolean;
|
|
||||||
queryParams?: Params | null;
|
queryParams?: Params | null;
|
||||||
queryParamsHandling?: QueryParamsHandling | null;
|
queryParamsHandling?: QueryParamsHandling | null;
|
||||||
relativeTo?: ActivatedRoute | null;
|
relativeTo?: ActivatedRoute | null;
|
||||||
|
|
|
@ -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 */
|
/** @nodoc */
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
onClick(): boolean {
|
onClick(): boolean {
|
||||||
|
@ -234,7 +223,6 @@ export class RouterLink implements OnChanges {
|
||||||
relativeTo: this.route,
|
relativeTo: this.route,
|
||||||
queryParams: this.queryParams,
|
queryParams: this.queryParams,
|
||||||
fragment: this.fragment,
|
fragment: this.fragment,
|
||||||
preserveQueryParams: attrBoolValue(this.preserve),
|
|
||||||
queryParamsHandling: this.queryParamsHandling,
|
queryParamsHandling: this.queryParamsHandling,
|
||||||
preserveFragment: attrBoolValue(this.preserveFragment),
|
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 */
|
/** @nodoc */
|
||||||
ngOnChanges(changes: SimpleChanges): any {
|
ngOnChanges(changes: SimpleChanges): any {
|
||||||
this.updateTargetUrlAndHref();
|
this.updateTargetUrlAndHref();
|
||||||
|
@ -399,7 +376,6 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
|
||||||
relativeTo: this.route,
|
relativeTo: this.route,
|
||||||
queryParams: this.queryParams,
|
queryParams: this.queryParams,
|
||||||
fragment: this.fragment,
|
fragment: this.fragment,
|
||||||
preserveQueryParams: attrBoolValue(this.preserve),
|
|
||||||
queryParamsHandling: this.queryParamsHandling,
|
queryParamsHandling: this.queryParamsHandling,
|
||||||
preserveFragment: attrBoolValue(this.preserveFragment),
|
preserveFragment: attrBoolValue(this.preserveFragment),
|
||||||
});
|
});
|
||||||
|
|
|
@ -104,14 +104,6 @@ export interface UrlCreationOptions {
|
||||||
*/
|
*/
|
||||||
fragment?: string;
|
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.
|
* How to handle query parameters in the router link for the next navigation.
|
||||||
* One of:
|
* One of:
|
||||||
|
@ -1104,23 +1096,12 @@ export class Router {
|
||||||
* router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
|
* router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
createUrlTree(commands: any[], navigationExtras: UrlCreationOptions = {}): UrlTree {
|
createUrlTree(commands: any[], navigationExtras: NavigationExtras = {}): UrlTree {
|
||||||
const {
|
const {relativeTo, queryParams, fragment, queryParamsHandling, preserveFragment} =
|
||||||
relativeTo,
|
navigationExtras;
|
||||||
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 a = relativeTo || this.routerState.root;
|
const a = relativeTo || this.routerState.root;
|
||||||
const f = preserveFragment ? this.currentUrlTree.fragment : fragment;
|
const f = preserveFragment ? this.currentUrlTree.fragment : fragment;
|
||||||
let q: Params|null = null;
|
let q: Params|null = null;
|
||||||
if (queryParamsHandling) {
|
|
||||||
switch (queryParamsHandling) {
|
switch (queryParamsHandling) {
|
||||||
case 'merge':
|
case 'merge':
|
||||||
q = {...this.currentUrlTree.queryParams, ...queryParams};
|
q = {...this.currentUrlTree.queryParams, ...queryParams};
|
||||||
|
@ -1131,9 +1112,6 @@ export class Router {
|
||||||
default:
|
default:
|
||||||
q = queryParams || null;
|
q = queryParams || null;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
q = preserveQueryParams ? this.currentUrlTree.queryParams : queryParams || null;
|
|
||||||
}
|
|
||||||
if (q !== null) {
|
if (q !== null) {
|
||||||
q = this.removeEmptyProps(q);
|
q = this.removeEmptyProps(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2137,7 +2137,7 @@ describe('Integration', () => {
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'someRoot',
|
selector: 'someRoot',
|
||||||
template:
|
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 {
|
class RootCmpWithLink {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue