562 Commits

Author SHA1 Message Date
Igor Minar
14abc68ccf docs(common): rewrite docs for NgForOf#ngForTrackBy ()
Clarify the prupose of the tracking function and document how to create a good one.

Fixes 

PR Close 
2021-05-26 20:05:39 +00:00
Andrew Scott
9f50495f28 docs: update date pipe api reference to indicate it is a pure pipe ()
This note was included in  but the PR was closed without being merged.

Fixes 

PR Close 
2021-05-25 22:10:32 +00:00
Andrew Scott
3fe8762376 docs: clarify location.subscribe behavior ()
`Location.go` does not trigger the browser's `popstate` event because
the Angular Router uses `pushState` and `replaceState`. This can be
confusing when calling `Location.go` and using `Location.subscribe`.
This commit clarifies the behavior of `Location.subscribe` and points
developers to the `onUrlChanges` subscription instead.

Fixes 

PR Close 
2021-05-25 17:57:52 +00:00
Joey Perrott
267500e3df build(common): update supported range of node versions to be less restrictive ()
Update the supported range of node versions for to be less restrictive, no longer causing
yarn or npm to fail engine's checks for future versions of node.

While this change will no longer cause yarn or npm to fail these engine's check, this does
not reflect a change in the officially supported versions of node for Angular.  Angular
continues to maintain support for Active LTS and Maintenance LTS versions of node.

PR Close 
2021-05-25 17:48:45 +00:00
Joey Perrott
2dd956421c build: remove publishConfig entry from package.json entries ()
Remove publishConfig property from the package.json entry for each of the entries in
the publish configuration.  Using the wombat proxy is now ensured/managed by the
ng-dev release tooling.

PR Close 
2021-05-18 15:41:33 -07:00
Ajit Singh
4bc3cf216d feat(common): add URLSearchParams to request body ()
URLSearch params are by default supported in the browser but are not supported by angular/http package added support for URLSearchParams

Fixes 

PR Close 
2021-05-07 10:45:02 -04:00
va-stefanek
640ec7828f refactor(common): change missing NgSwitch provider error message ()
change error message of invalid NgSwitch use and add corner cases tests

PR Close 
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 () ()
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 
2021-05-04 21:09:58 -07:00
Gourav102
378bb04d7b docs(common): Corrected the wrong formatting ()
Removed the extra backtick character for `getLocaleTimeFormat()` link.
PR Close 
2021-05-04 21:08:53 -07:00
Ben Lesh
e387d22f83 fix(core): AsyncPipe now compatible with RxJS 7 ()
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 
2021-05-04 08:32:48 -07:00
Gopal Jayaraman
6e11febf60 fix(common): add right ContentType for boolean values with HttpClient request body() ()
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 
2021-05-03 10:00:16 -07:00
Joey Perrott
bce3194f78 fix(common): update supported range of node versions to only include LTS versions ()
Update the supported range of node versions for Angular to only include supported LTS versions.

PR Close 
2021-04-26 15:21:13 -07:00
Kristiyan Kostadinov
1aebf165db fix(common): viewport scroller not finding elements inside the shadow DOM ()
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 .

PR Close 
2021-04-15 12:47:05 -07:00
Joey Perrott
e0250e567a feat(common): update supported range of node versions ()
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 
2021-04-14 09:40:18 -07:00
Ahmed Ayed
e05a6f3bb3 feat(common): add historyGo method to Location service ()
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 
2021-04-06 09:25:58 -07:00
Pete Bacon Darwin
7dfa446c4a fix(common): temporarily re-export and deprecate XhrFactory ()
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 
2021-04-01 11:26:11 -07:00
Alan Agius
c4628f29be refactor(common): remove XhrFactory re-export from @angular/common/http ()
This was only done temporary to allow migration in Google3. The removal breaking change message has already been included in 

PR Close 
2021-03-30 16:57:18 -07:00
Alan Agius
e0028e5741 fix(platform-browser): configure XhrFactory to use BrowserXhr ()
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 

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

PR Close 
2021-03-17 09:10:25 -07:00
FDIM
1644d64398 feat(compiler-cli): introduce HttpContext request context ()
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 
2021-03-15 10:33:48 -07:00
Kristiyan Kostadinov
3c66b100dd perf(common): remove unused methods from DomAdapter ()
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 
2021-03-10 11:48:24 -08:00
Theoklitos Bampouris
e29a29ce9f docs(common): change misspelled constant ()
Change misspelled constant from LOCAL_ID to LOCALE_ID
PR Close 
2021-03-09 08:57:38 -08:00
Igor Minar
03d47d5701 feat(core): manually annotate de-sugarred core tree-shakable providers with @pureOrBreakMyCode ()
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 
2021-03-08 10:30:08 -08:00
Quentin Monmert
c676ec1ce5 docs: fix some typos in angular.io examples ()
This commit updates example code to make the spacing more consistent.

PR Close 
2021-03-05 15:08:11 -08:00
arturovt
38524c4d29 fix(common): cleanup location change listeners when the root view is removed ()
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 

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

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

PR Close 
2021-02-26 15:42:29 -08:00
cexbrayat
91cdc11aa0 fix(common): allow number or boolean as http params ()
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 

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 
2021-02-26 12:03:50 -08:00
Kristiyan Kostadinov
d3705b3284 fix(common): avoid mutating context object in NgTemplateOutlet ()
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 .

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

Fixes 

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

Fixes 

PR Close 
2021-02-10 16:03:06 -08:00
Dmitry Drobyshev
38972653fa fix(http): emit error on XMLHttpRequest abort event ()
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 

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

Fixes 

PR Close 
2021-02-10 11:04:37 -08:00
arturovt
61a0b6de6d fix(http): complete the request on timeout ()
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 

PR Close 
2021-02-09 14:44:17 -08:00
Pete Bacon Darwin
1579df243d fix(core): ensure the type T of EventEmitter<T> can be inferred ()
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 

PR Close 
2021-02-03 09:07:29 -08:00
Pete Bacon Darwin
ca0f6e6eed fix(common): parse YYYY strings as UTC dates ()
In b6cd38ff055f003f92fff4c3e27d165fb4437057 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 

PR Close 

PR Close 
2021-01-29 11:14:05 -08:00
Pete Bacon Darwin
b6cd38ff05 fix(common): parse YYYY-MM strings as UTC dates ()
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 

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

PR Close 
2021-01-28 09:10:48 -08:00
Quentin Focheux
6fe3a1de7f feat(http): expose a list of human-readable http status codes ()
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 

PR Close 
2021-01-28 09:10:48 -08:00
Joey Perrott
39b3cbbdf5 build: update .bazelversion ()
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 
2021-01-26 11:35:54 -08:00
Harun Urhan
575a2d162c feat(common): implement appendAll() method on HttpParams ()
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 

PR Close 
2021-01-21 14:01:34 -08:00
Alexey Elin
cf02cf1e18 docs: remove duplicated the ()
PR Close 
2021-01-14 11:33:57 -08:00
Andrew Scott
4eac7e6436 fix(router): Router should focus element after scrolling ()
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 

PR Close 
2021-01-05 09:48:48 -08:00
Andrew Scott
112dff81b0 test(router): update scroller tests to use real objects ()
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 
2021-01-05 09:48:48 -08:00
Andrew Scott
a55f581add refactor(router): Remove unused property in BrowserViewportScroller ()
The `BrowserViewportScroller` injects but does not use the `ErrorHandler`.
This commit removes the `ErrorHandler` from the constructor.

PR Close 
2021-01-05 09:48:47 -08:00
Julien
42d478b16a docs(common): use table layout for Pre-defined format options ()
easier to read
PR Close 
2020-12-09 09:11:03 -08:00
arturovt
f022efa06f perf(common): use ngDevMode to tree-shake warnings ()
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 
2020-12-04 16:08:00 -08:00
Nicholas Papadopoulos
7851a254d8 docs(common): fix typo in HttpClient docs ()
PR Close 
2020-12-02 11:16:43 -08:00