Commit Graph

556 Commits

Author SHA1 Message Date
va-stefanek 640ec7828f refactor(common): change missing NgSwitch provider error message (#41704)
change error message of invalid NgSwitch use and add corner cases tests

PR Close #41704
2021-05-06 15:44:38 -04:00
Gopal Jayaraman 6b8baad940 fix(common): add body as an optional property on the options of HttpClient.delete (#19438) (#41723)
adding optional body for HTTP delete request options. This new param added as an optional so won't break the existing code also provide the capability the send the body when and where it required.

PR Close #41723
2021-05-04 21:09:58 -07:00
Gourav102 378bb04d7b docs(common): Corrected the wrong formatting (#41945)
Removed the extra backtick character for `getLocaleTimeFormat()` link.
PR Close #41945
2021-05-04 21:08:53 -07:00
Ben Lesh e387d22f83 fix(core): AsyncPipe now compatible with RxJS 7 (#41590)
Adds a fix to make sure that RxJS v7 Observable is compatible with AsyncPipe. This is a typings-only change.
For more information see: https://github.com/microsoft/TypeScript/issues/43643

PR Close #41590
2021-05-04 08:32:48 -07:00
Gopal Jayaraman 6e11febf60 fix(common): add right ContentType for boolean values with HttpClient request body(#38924) (#41885)
currently a boolean as body is seen as text/plain, where is should be seen as application/json, since it is valid JSON, like numbers.

PR Close #41885
2021-05-03 10:00:16 -07:00
Joey Perrott bce3194f78 fix(common): update supported range of node versions to only include LTS versions (#41822)
Update the supported range of node versions for Angular to only include supported LTS versions.

PR Close #41822
2021-04-26 15:21:13 -07:00
Kristiyan Kostadinov 1aebf165db fix(common): viewport scroller not finding elements inside the shadow DOM (#41644)
The `ViewportScroller` figures out which element to scroll into view using `document.getElementById`. The problem is that it won't find elements inside the shadow DOM.

These changes add some extra logic that goes through all the shadow roots to look for the element.

Fixes #41470.

PR Close #41644
2021-04-15 12:47:05 -07:00
Joey Perrott e0250e567a feat(common): update supported range of node versions (#41544)
Update the supported range of node versions for Angular.  Angular now
supports node >=12.14.1 to <16.0.0, dropping support for Node v10.

PR Close #41544
2021-04-14 09:40:18 -07:00
Ahmed Ayed e05a6f3bb3 feat(common): add `historyGo` method to `Location` service (#38890)
Add new method `historyGo`, that will let
the user navigate to a specific page from session history identified by its
relative position to the current page.

We add some tests to `location_spec.ts` to validate the behavior of the
`historyGo` and `forward` methods.

Add more tests for `location_spec` to test `location.historyGo(0)`, `location.historyGo()`,
`location.historyGo(100)` and `location.historyGo(-100)`. We also add new tests for
`Integration` spec to validate the navigation when we using
`location#historyGo`.

Update the `historyGo` function docs

Note that this was made an optional function in the abstract classes to
avoid a breaking change. Because our location classes use `implements PlatformLocation`
rather than `extends PlatformLocation`, simply adding a default
implementation was not sufficient to make this a non-breaking change.
While we could fix the classes internal to Angular, this would still have been
a breaking change for any external developers who may have followed our
implementations as an example.

PR Close #38890
2021-04-06 09:25:58 -07:00
Pete Bacon Darwin 7dfa446c4a 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
2021-04-01 11:26:11 -07:00
Alan Agius c4628f29be refactor(common): remove `XhrFactory` re-export from `@angular/common/http` (#41370)
This was only done temporary to allow migration in Google3. The removal breaking change message has already been included in #41313

PR Close #41370
2021-03-30 16:57:18 -07:00
Alan Agius e0028e5741 fix(platform-browser): configure `XhrFactory` to use `BrowserXhr` (#41313)
With this change we move `XhrFactory` to the root entrypoint of `@angular/commmon`, this is needed so that we can configure `XhrFactory` DI token at a platform level, and not add a dependency  between `@angular/platform-browser` and `@angular/common/http`.

Currently, when using `HttpClientModule` in a child module on the server, `ReferenceError: XMLHttpRequest is not defined` is being thrown because the child module has its own Injector and causes `XhrFactory` provider to be configured to use `BrowserXhr`.
Therefore, we should configure the `XhrFactory` at a platform level similar to other Browser specific providers.

BREAKING CHANGE:

`XhrFactory` has been moved from `@angular/common/http` to `@angular/common`.

**Before**
```ts
import {XhrFactory} from '@angular/common/http';
```

**After**
```ts
import {XhrFactory} from '@angular/common';
```

Closes #41311

PR Close #41313
2021-03-29 15:14:16 -07:00
Kristiyan Kostadinov 59ef40988e feat(core): support TypeScript 4.2 (#41158)
Updates the repo to TypeScript 4.2 and tslib 2.1.0.

PR Close #41158
2021-03-17 09:10:25 -07:00
FDIM 1644d64398 feat(compiler-cli): introduce HttpContext request context (#25751)
A long-requested feature for HttpClient is the ability to store and retrieve
custom metadata for requests, especially in interceptors. This commit
implements this functionality via a new context object for requests.

Each outgoing HttpRequest now has an associated "context", an instance of
the HttpContext class. An HttpContext can be provided when making a request,
or if not then an empty context is created for the new request. This context
shares its lifecycle with the entire request, even across operations that
change the identity of the HttpRequest instance such as RxJS retries.

The HttpContext functions as an expando. Users can create typed tokens as instances of HttpContextToken, and
read/write a value for the key from any HttpContext object.

This commit implements the HttpContext functionality. A followup commit will
add angular.io documentation.

PR Close #25751
2021-03-15 10:33:48 -07:00
Kristiyan Kostadinov 3c66b100dd perf(common): remove unused methods from DomAdapter (#41102)
The `DomAdapter` is present in all Angular apps and its methods aren't tree shakeable.
These changes remove the methods that either aren't being used anymore or were only
used by our own tests. Note that these changes aren't breaking, because the adapter
is an internal API.

The following methods were removed:
* `getProperty` - only used within our own tests.
* `log` - Guaranteed to be defined on `console`.
* `logGroup` and `logGroupEnd` - Only used in one place. It was in the DomAdapter for built-in null checking.
* `logGroupEnd` - Only used in one place. It was placed in the DomAdapter for built in null checking.
* `performanceNow` - Only used in one place that has to be invoked through the browser console.
* `supportsCookies` - Unused.
* `getCookie` - Unused.
* `getLocation` and `getHistory` - Only used in one place which appears to have access to the DOM
already, because it had direct accesses to `window`. Furthermore, even if this was being used
in a non-browser context already, the `DominoAdapter` was set up to throw an error.

The following APIs were changed to be more compact:
* `supportsDOMEvents` - Changed to a readonly property.
* `remove` - No longer returns the removed node.

PR Close #41102
2021-03-10 11:48:24 -08:00
Theoklitos Bampouris e29a29ce9f docs(common): change misspelled constant (#41136)
Change misspelled constant from LOCAL_ID to LOCALE_ID
PR Close #41136
2021-03-09 08:57:38 -08:00
Igor Minar 03d47d5701 feat(core): manually annotate de-sugarred core tree-shakable providers with @pureOrBreakMyCode (#41096)
This is necessary for closure compiler in order to support cross chunk code motion.

I'm intentionally not annotating these call sites with @__PURE__ at the moment because
build-optimizer does it within the Angular CLI build. In the future we might want to consider
having both annotations here in case we change how build-optimizer works.

PR Close #41096
2021-03-08 10:30:08 -08:00
Quentin Monmert c676ec1ce5 docs: fix some typos in angular.io examples (#41093)
This commit updates example code to make the spacing more consistent.

PR Close #41093
2021-03-05 15:08:11 -08:00
arturovt 38524c4d29 fix(common): cleanup location change listeners when the root view is removed (#40867)
In the new behavior Angular cleanups `popstate` and `hashchange` event listeners
when the root view gets destroyed, thus event handlers are not added twice
when the application is bootstrapped again.

BREAKING CHANGE:

Methods of the `PlatformLocation` class, namely `onPopState` and `onHashChange`,
used to return `void`. Now those methods return functions that can be called
to remove event handlers.

PR Close #31546

PR Close #40867
2021-03-04 13:09:04 -08:00
Chris ad40fcae7a docs: improve documentation on how to pass a stringified parameter list to HttpClient (#41010)
Fixes #40618

PR Close #41010
2021-03-04 11:00:23 -08:00
Kapunahele Wong 6c783c7fcb docs: rewrite structural-directives.md (#40015)
PR Close #40015
2021-03-01 15:32:26 -08:00
Chris bebdeba5fd docs: improve description, examples of DecimalPipe's digitsInfo parameter (#40714)
Fixes #40671

PR Close #40714
2021-02-26 15:42:29 -08:00
cexbrayat 91cdc11aa0 fix(common): allow number or boolean as http params (#40663)
This change fixes an incompatibility between the old `@angular/http` package
and its successor (`@angular/common/http`) by re-introducing the types that were supported before.

It now allows to use number and boolean directly as HTTP params, instead of having to convert it to string first.

Before:

    this.http.get('/api/config', { params: { page: `${page}` } });

After:

    this.http.get('/api/config', { params: { page }});

`HttpParams` has also been updated to have most of its methods accept number or boolean values.

Fixes #23856

BREAKING CHANGE:

The methods of the `HttpParams` class now accept `string | number | boolean`
instead of `string` for the value of a parameter.
If you extended this class in your application,
you'll have to update the signatures of your methods to reflect these changes.

PR Close #40663
2021-02-26 12:03:50 -08:00
Kristiyan Kostadinov d3705b3284 fix(common): avoid mutating context object in NgTemplateOutlet (#40360)
Currently `NgTemplateOutlet` recreates its view if its template is swapped out or a context
object with a different shape is passed in. If an object with the same shape is passed in,
we preserve the old view and we mutate the previous object. This mutation of the original
object can be undesirable if two objects with the same shape are swapped between two
different template outlets.

The current behavior is a result of a limitation in `core` where the `context` of an embedded
view is read-only, however a previous commit made it writeable.

These changes resolve the context mutation issue and clean up a bunch of unnecessary
logic from `NgTemplateOutlet` by taking advantage of the earlier change.

Fixes #24515.

PR Close #40360
2021-02-23 08:14:02 -08:00
Jefiozie f340a5b9f2 fix(http): ignore question mark when params are parsed (#40610)
This commit adds a fix where params will ignore questions marks when
parsed.

Fixes #28722

PR Close #40610
2021-02-19 12:11:39 -08:00
kirjs c56ecab515 feat(common): support ICU standard "stand alone day of week" with `DatePipe` (#40766)
This commit adds support for Finnish full date formatting,
as well as `c/cc/ccc/cccc/ccccc/cccccc` date formats in the `DatePipe`.

Fixes #26922

PR Close #40766
2021-02-10 16:03:06 -08:00
Dmitry Drobyshev 38972653fa fix(http): emit error on XMLHttpRequest abort event (#40767)
Before this change, when Google Chrome cancels a XMLHttpRequest, an Observable of the response
never finishes. This happens, for example, when you put your computer to sleep or just press
Ctrl+S to save the browser page. After this commit, if request is canceled or aborted an
appropriate Observable will be completed with an error.

Fixes #22324

PR Close #40767
2021-02-10 11:13:05 -08:00
Alexey Elin ddff6b63d7 docs: fix absent documentation for digitsInfo parameter in the API docs (#40746)
PR Close #40746
2021-02-10 11:09:09 -08:00
abarghoud 03f0b157c1 fix(common): date is not correctly formatted when year is between 0 and 99 (#40448)
use setFullYear method when parsing date to avoid javascript date factory behaviour

Fixes #40377

PR Close #40448
2021-02-10 11:04:37 -08:00
arturovt 61a0b6de6d fix(http): complete the request on timeout (#39807)
When using the [timeout attribute](https://xhr.spec.whatwg.org/#the-timeout-attribute) and an XHR
request times out, browsers trigger the `timeout` event (and execute the XHR's `ontimeout`
callback). Additionally, Safari 9 handles timed-out requests in the same way, even if no `timeout`
has been explicitly set on the XHR.

In the above cases, `HttpClient` would fail to capture the XHR's completing (with an error), so
the corresponding `Observable` would never complete.

PR Close #26453

PR Close #39807
2021-02-09 14:44:17 -08:00
Pete Bacon Darwin 1579df243d fix(core): ensure the type `T` of `EventEmitter<T>` can be inferred (#40644)
The `AsyncPipe.transform<T>(emitter)` method must infer the `T`
type from the `emitter` parameter. Since we changed the `AsyncPipe`
to expect a `Subscribable<T>` rather than `Observable<T>` the
`EventEmitter.subscribe()` method needs to have a tighter signature.
Otherwise TypeScript struggles to infer the type and ends up making
it `unknown`.

Fixes #40637

PR Close #40644
2021-02-03 09:07:29 -08:00
Pete Bacon Darwin ca0f6e6eed fix(common): parse `YYYY` strings as UTC dates (#40629)
In b6cd38ff05 we fixed the DatePipe so
that when it parsed date strings that looked like `YYYY-MM` it created a UTC
date that was not affected by the local timezone of the JavaScript engine.

This commit does the same for date strings of the form `YYYY`.

(Note that the previous commit, mentioned above, attempted to fix this case
too but the test was not actually checking the correct input string.)

Fixes #33944

PR Close #40620

PR Close #40629
2021-01-29 11:14:05 -08:00
Pete Bacon Darwin b6cd38ff05 fix(common): parse `YYYY-MM` strings as UTC dates (#40620)
In 2aba8b0 we fixed the DatePipe so that when it parsed date strings
that looked like `YYYY-MM-DD` it created a UTC date that was not
affected by the local timezone of the JavaScript engine.

This commit does the same for date strings of the form `YYYY-MM`
and `YYYY`.

Fixes #33944

PR Close #40620
2021-01-28 16:00:57 -08:00
Quentin Focheux baadd109aa test(http): use HttpStatusCode enum in tests (#23548)
Now that we have introduced human-readable http status codes,
we can use it in our tests to improve clarity.

PR Close #23548
2021-01-28 09:10:48 -08:00
Quentin Focheux 6fe3a1de7f feat(http): expose a list of human-readable http status codes (#23548)
They aim to improve code readability.
Since they are defined by `const enum` they have zero runtime performance impact
over just using constant literals.

Fixes #23543

PR Close #23548
2021-01-28 09:10:48 -08:00
Joey Perrott 39b3cbbdf5 build: update .bazelversion (#40579)
Update to the latest version of bazel.

`4.0.0` introduced a breaking change on unnecessary backslashes and these
instance are corrected in this change.

PR Close #40579
2021-01-26 11:35:54 -08:00
Harun Urhan 575a2d162c feat(common): implement `appendAll()` method on `HttpParams` (#20930)
Adds an `appendAll()` method to `HttpParams` that can construct the HTTP
request/response body from an object of parameters and values.

This avoids calling `append()` multiple times when multiple parameters
need to be added.

Fixes #20798

PR Close #20930
2021-01-21 14:01:34 -08:00
Alexey Elin cf02cf1e18 docs: remove duplicated the (#40434)
PR Close #40434
2021-01-14 11:33:57 -08:00
Andrew Scott 4eac7e6436 fix(router): Router should focus element after scrolling (#40241)
According to the [spec](https://html.spec.whatwg.org/#scroll-to-fragid),
we should attempt to set the browser focus after scrolling to a
fragment. Note that this change does not exactly follow the robust steps
outlined in the spec by finding a fallback target if the original is not
focusable. Instead, we simply attempt to focus the element by calling
`focus` on it, which will do nothing if the element is not focusable.

fixes #30067

PR Close #40241
2021-01-05 09:48:48 -08:00
Andrew Scott 112dff81b0 test(router): update scroller tests to use real objects (#40241)
The current tests in the router scroller are
[change-detector tests](https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html)
and do not ensure the correct behavior of the scroller.
This commit updates the tests to assert actual scrolling behavior of the
browser.

PR Close #40241
2021-01-05 09:48:48 -08:00
Andrew Scott a55f581add refactor(router): Remove unused property in `BrowserViewportScroller` (#40241)
The `BrowserViewportScroller` injects but does not use the `ErrorHandler`.
This commit removes the `ErrorHandler` from the constructor.

PR Close #40241
2021-01-05 09:48:47 -08:00
Julien 42d478b16a docs(common): use table layout for Pre-defined format options (#40036)
easier to read
PR Close #40036
2020-12-09 09:11:03 -08:00
arturovt f022efa06f perf(common): use `ngDevMode` to tree-shake warnings (#39964)
This commit adds ngDevMode guard to show warnings only
in dev mode (similar to how things work in other parts of Ivy runtime code).
The ngDevMode flag helps to tree-shake these warnings from production builds
(in dev mode everything will work as it works right now) to decrease production bundle size.

PR Close #39964
2020-12-04 16:08:00 -08:00
Nicholas Papadopoulos 7851a254d8 docs(common): fix typo in HttpClient docs (#39904)
PR Close #39904
2020-12-02 11:16:43 -08:00
Fabian Wiles 7a5bc95614 refactor(http): inline HttpObserve (#18417)
Inline `HttpObserve` for better type safety.

Fix #18146

PR Close #18417
2020-12-01 12:13:04 -08:00
Tzimpoulas Nikos 1539c64fb0 docs(common): change HTTPResponse to HttpResponse (#39860)
PR Close #39860
2020-11-30 12:04:34 -08:00
Kapunahele Wong 2c275f6d7a docs: archive template expression operators doc, move pipes precedence section (#39170)
Archives most of the content in the template expression operators doc.
The pipes precedence section that was originally in
template expression operators moves into the pipes doc
with some editing and an addition of a ternary example.

PR Close #39170
2020-11-24 08:41:18 -08:00
Gautier Pelloux-Prayer 938abc03bc docs(http): Add mention to default value 'OK' for statusText. #23334 (#23494)
PR Close #23494
2020-11-23 08:31:24 -08:00
David-Emmanuel DIVERNOIS c7f4abf18a feat(common): allow any Subscribable in async pipe (#39627)
As only methods from the Subscribable interface are currently used in the
implementation of the async pipe, it makes sense to make it explicit so
that it works successfully with any other implementation instead of
only Observable.

PR Close #39627
2020-11-23 08:28:11 -08:00
Marcono1234 3e1e5a15ba docs: update links to use HTTPS as protocol (#39718)
PR Close #39718
2020-11-20 12:52:16 -08:00