Skip to content

Commit 7dfa446

Browse files
petebacondarwinalxhub
authored andcommitted
fix(common): temporarily re-export and deprecate XhrFactory (#41393)
The moved `XhrFactory` still needs to be available from `@angular/common/http` for some libraries that were built prior to 12.0.0, otherwise they cannot be used in applications built post-12.0.0. This commit adds back the re-export of `XhrFactory` and deprecates it. PR Close #41393
1 parent 6391a4a commit 7dfa446

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

aio/content/guide/deprecations.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ v12 - v15
4040
| ----------------------------- | --------------------------------------------------------------------------- | ----------------- |
4141
| `@angular/common` | [`ReflectiveInjector`](#reflectiveinjector) | <!--v8--> v11 |
4242
| `@angular/common` | [`CurrencyPipe` - `DEFAULT_CURRENCY_CODE`](api/common/CurrencyPipe#currency-code-deprecation) | <!--v9--> v11 |
43+
| `@angular/common/http` | [`XhrFactory`](api/common/http/XhrFactory) | <!--v12--> v15 |
4344
| `@angular/core` | [`DefaultIterableDiffer`](#core) | <!--v7--> v11 |
4445
| `@angular/core` | [`ReflectiveKey`](#core) | <!--v8--> v11 |
4546
| `@angular/core` | [`RenderComponentType`](#core) | <!--v7--> v11 |
@@ -82,6 +83,14 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
8283
| [`CurrencyPipe` - `DEFAULT_CURRENCY_CODE`](api/common/CurrencyPipe#currency-code-deprecation) | `{provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'}` | v9 | From v11 the default code will be extracted from the locale data given by `LOCAL_ID`, rather than `USD`. |
8384

8485

86+
{@a common-http}
87+
### @angular/common/http
88+
89+
| API | Replacement | Deprecation announced | Notes |
90+
| -------------------------------------------- | ------------------------------------ | --------------------- | ----- |
91+
| [`XhrFactory`](api/common/http/XhrFactory) | `XhrFactory` in `@angular/common` | v12 | The `XhrFactory` has moved from `@angular/common/http` to `@angular/common`. |
92+
93+
8594
{@a core}
8695
### @angular/core
8796

goldens/public-api/common/http/http.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ export declare interface HttpUserEvent<T> {
19301930
}
19311931

19321932
export declare class HttpXhrBackend implements HttpBackend {
1933-
constructor(xhrFactory: XhrFactory);
1933+
constructor(xhrFactory: XhrFactory_2);
19341934
handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
19351935
}
19361936

@@ -1947,3 +1947,6 @@ export declare class JsonpInterceptor {
19471947
constructor(jsonp: JsonpClientBackend);
19481948
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
19491949
}
1950+
1951+
/** @deprecated */
1952+
export declare type XhrFactory = XhrFactory_2;

packages/common/http/public_api.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {XhrFactory as XhrFactory_fromAngularCommon} from '@angular/common';
10+
11+
/**
12+
* A wrapper around the `XMLHttpRequest` constructor.
13+
*
14+
* @publicApi
15+
* @see `XhrFactory`
16+
* @deprecated
17+
* `XhrFactory` has moved, please import `XhrFactory` from `@angular/common` instead.
18+
*/
19+
export type XhrFactory = XhrFactory_fromAngularCommon;
20+
/**
21+
* A wrapper around the `XMLHttpRequest` constructor.
22+
*
23+
* @publicApi
24+
* @see `XhrFactory`
25+
* @deprecated
26+
* `XhrFactory` has moved, please import `XhrFactory` from `@angular/common` instead.
27+
*/
28+
export const XhrFactory = XhrFactory_fromAngularCommon;
29+
930
export {HttpBackend, HttpHandler} from './src/backend';
1031
export {HttpClient} from './src/client';
1132
export {HttpContext, HttpContextToken} from './src/context';

0 commit comments

Comments
 (0)