Commit Graph

278 Commits

Author SHA1 Message Date
iRealNirmal a502279592 feat(forms): allow minLength/maxLength validator to be bound to `null` (#42565)
If the validator is bound to be `null` then no validation occurs and
attribute is not added to DOM.

For every validator type different PR will be raised as discussed in
https://github.com/angular/angular/pull/42378.

Closes #42267.

PR Close #42565
2021-07-21 22:35:59 +00:00
JoostK 51156f3f07 fix(core): allow proper type inference when `ngFor` is used with a `trackBy` function (#42692)
In #41995 the type of `TrackByFunction` was changed such that the
declaration of a `trackBy` function did not cause the item type to be
widened to the `trackBy`'s item type, which may be a supertype of the
iterated type. This has introduced situations where the template type
checker is now reporting errors for cases where a `trackBy` function is
no longer assignable to `TrackByFunction`.

This commit fixes the error by also including the item type `T` in
addition to the constrained type parameter `U`, allowing TypeScript to
infer an appropriate `T`.

Fixes #42609

PR Close #42692
2021-07-13 14:08:05 -07:00
Daniel Trevino 81dce5c664 fix(compiler-cli): check split two way binding (#42601)
Check for split two way binding when output is not declared to make error message clearer.

PR Close #42601
2021-07-13 08:47:11 -07:00
George Kalpakas 8b95816fc4 fix(docs-infra): log more SW debug info (#42776)
This commit expands the info printed to the console to help diagnose
ServiceWorker issues to include the [internal debug info][1] retrieved
from `/ngsw/state`. This will provide more useful data, such as the
activated SW's version, state, clients, recent operations and any recent
errors.

NOTE:
This temporarily increases the payload size. Removing this code and
reclaiming the payload size is being tracked in #41117.

[1]: https://angular.io/guide/service-worker-devops#locating-and-analyzing-debugging-information

PR Close #42776
2021-07-07 13:37:05 -07:00
George Kalpakas 40389940f9 build(docs-infra): update @angular/* to 12.1.1 (#42776)
Update `@angular/*` packages to latest 12.1.x versions (mainly to take
advantage of recent ServiceWorker improvements, such as #42607
and #42622).

PR Close #42776
2021-07-07 13:37:05 -07:00
George Kalpakas 6548a53bfc build(docs-infra): update payload sizes (#42776)
This commit updates the payload sizes for angular.io to make it easier
to identify payload size changes from an imminent update of `@angular/*`
packages.

PR Close #42776
2021-07-07 13:37:05 -07:00
Paul Gschwendtner e99af184ab build: update API goldens after api-extractor update (#42737)
Given we have updated API extractor to the most recent
version, we need to update the API goldens because the
latest version uses alias exports to avoid collisions with
default library globals (like `Event`).

PR Close #42737
2021-07-02 10:08:03 -07:00
Paul Gschwendtner 59fe159b78 build: update API goldens to reflect new tool (#42688)
Updates the TS API guardian goldens with their equivalents
based on the new shared dev-infra tool.

PR Close #42688
2021-06-30 11:43:48 -07:00
Paul Gschwendtner 9db69a9c9e build: use api-golden tool from dev-infra for testing public API (#42688)
Switches our TS API guardian targets to rather use the new tool from
dev-infra that relies on Microsoft's API extractor.

PR Close #42688
2021-06-30 11:43:48 -07:00
Alex Rickabaugh e83d7cb2d3 refactor(compiler-cli): support xi18n in ngtsc (#42485)
xi18n is the operation of extracting i18n messages from templates in the
compilation. Previously, only View Engine was able to perform xi18n. This
commit implements xi18n in the Ivy compiler, and a copy of the View Engine
test for Ivy verifies that the results are identical.

PR Close #42485
2021-06-21 16:50:28 +00:00
George Kalpakas 0c105c38da fix(docs-infra): make `NotificationComponent` elements non-focusable when hidden (#42584)
Previously, the `NotificationComponent` would be hidden by reducing its
height to `0`. This allowed for a smoother hide animation when closing
the notification, but left the component's interactive elements
focusable via keyboard navigation. This was confusing for users, because
the focused elements would not be visible on the page.

This commit fixes the issue be also setting the `display` CSS property
to `none` when the `NotificationComponent` is hidden, thus ensuring that
its contents are not focusable via keyboard navigation.
(This does not affect the hide animation, since the `display` style is
not animatable and is only applied at the end of the animation.)

PR Close #42584
2021-06-18 17:32:26 +00:00
George Kalpakas 29302e3baa fix(docs-infra): remove redundant `MatIcon` element (#42584)
Previously, we included a dummy `MatIcon` element in `AppComponent` in
order to ensure that the `Material Icons` font would be requested (and
thus cached by the ServiceWorker) on every navigation. However, #41129
introduced the `ThemeToggleComponent`, which will be present on all
pages (since it is located in the top-menu) and relies on the
`Material Icons` font. Therefore, the work-around for loading the
`Material Icons` font is no longer necessary.

This commit removes the now redundant `MatIcon` from `AppComponent`.

PR Close #42584
2021-06-18 17:32:26 +00:00
George Kalpakas fd8f9ab4e8 fix(docs-infra): convert external links to `MatIconButton`s (#42584)
This commit changes the anchor elements used for external links to
`MatIconButton`s. While the appearance remains the same (with the
exception of hover/focus styles), this better aligns the styling of
external link icons with other nearby icon buttons (i.e. the theme
toggle) and alows as to simplify the CSS for external links (since much
of their styling is handled by Angular Material).

PR Close #42584
2021-06-18 17:32:26 +00:00
George Kalpakas 0f6ebe1ab5 refactor(docs-infra): remove redundant CSS rule (#42584)
Since we now use SVG for external link icons, there are no `<img>`
elements inside the anchor elements. So, the CSS rule does not match any
element and can be removed.

PR Close #42584
2021-06-18 17:32:26 +00:00
George Kalpakas 12644486f4 ci: start tracking CSS payload sizes for angular.io (#42584)
Previously, we only tracked the sizes of the eagerly loaded JS bundles.
However, the CSS styles (which also have a non-negligible size) must
also be downloaded and parsed by the browser, thus affecting the initial
rendering time.

This commit starts tracking the CSS styles payload sizes.
(Originally discussed in
https://github.com/angular/angular/pull/42584#discussion_r653787961)

PR Close #42584
2021-06-18 17:32:26 +00:00
Pete Bacon Darwin b0592c1be6 build(docs-infra): use case-insensitive encoding for content files (#42414)
To avoid having content files that have the same file path on case-insensitive
file-systems, we now encode the paths to remove uppercase characters.

PR Close #42414
2021-06-17 18:14:53 +00:00
Kristiyan Kostadinov 873229f24b feat(core): add opt-in test module teardown configuration (#42566)
We currently have two long-standing issues related to how `TestBed` tests are torn down:
1. The dynamically-created test module isn't going to be destroyed, preventing the `ngOnDestroy` hooks on providers from running and keeping the component `style` nodes in the DOM.
2. The test root elements aren't going to be removed from the DOM. Instead, they will be removed whenever another test component is created.

By themselves, these issues are easy to resolve, but given how long they've been around, there are a lot of unit tests out there that depend on the broken behavior.

These changes address the issues by introducing APIs that allow users to opt into the correct test teardown behavior either at the application level via `TestBed.initTestEnvironment` or the test suite level via `TestBed.configureTestingModule`.

At the moment, the new teardown behavior is opt-in, but the idea is that we'll eventually make it opt-out before removing the configuration altogether.

Fixes #18831.

PR Close #42566
2021-06-17 18:03:47 +00:00
George Kalpakas 828fde6e0d feat(docs-infra): implement popup to inform about the use of cookies (#42259)
This commit adds a popup to angular.io to inform the user about the use
of cookies. Once the user confirms having read the info, the popup will
not be shown on subsequent visits.

This commit is partly based on angular/material.angular.io#988.

Fixes #42209

PR Close #42259
2021-06-14 09:54:08 -07:00
George Kalpakas 1a6a79b63a refactor(docs-infra): provide `local-/sessionStorage` via DI (#42259)
Previously, we had the same logic in a couple of places to safely access
the `Window`'s `local-/sessionStorage` and provide a no-op fallback if
necessary. Soon, we will need the same logic for the cookies popup
(see #42209).

This commit reduces code duplication by providing
`local-/sessionStorage` as injectables and sharing the logic for
accessing them safely. This also makes it easier to mock the storage in
tests without having to mess with the actual `Window` object.

NOTE:
This commit actually decreases the payload size in the `main` bundle by
40B.

PR Close #42259
2021-06-14 09:54:08 -07:00
George Kalpakas edf3e5a9cf build(docs-infra): align code with new CLI v12 apps (#42259)
This commit aligns the angular.io config files more closely to how a
newly generated CLI v12 app would look like. This helps validate the
setup and makes it easier to apply new chages in the future (by
preventing the angular.io layout from deviating too much from the
default new app layout).

PR Close #42259
2021-06-14 09:54:08 -07:00
Ahmed Ayed efb440eb2f refactor(router): compute correct history restoration when navigation is cancelled (#38884)
We can’t determine whether the user actually meant the `back` or
the `forward` using the popstate event (triggered by a browser
back/forward)
so we instead need to store information on the state and compute the
distance the user is traveling withing the browser history.
So by using the `History#go` method,
we can bring the user back to the page where he is supposed to be after
performing the action.

implementation for #13586

PR Close #38884
2021-06-10 14:09:21 -07:00
JiaLiPassion 299f92c3b6 fix(zone.js): only one listener should also re-throw an error correctly (#41868)
Close #41867

In the previous commit https://github.com/angular/angular/pull/41562#issuecomment-822696973,
the error thrown in the event listener will be caught and re-thrown, but there is a bug
in the commit, if there is only one listener for the specified event name, the error
will not be re-thrown, so this commit fixes the issue and make sure the error is re-thrown.

PR Close #41868
2021-06-10 09:24:03 -07:00
Dylan Hunn 34ce635e3a feat(forms): undo revert and add ng-submitted class to forms that have been submitted. (#42132) (#42132)
As previously discussed in pull/31070 and issues/30486, this would be useful because it is often desirable to apply styles to fields that are both `ng-invalid` and `ng-pristine` after the first attempt at form submission, but Angular does not provide any simple way to do this (although evidently Angularjs did). This will now be possible with a descendant selector such as `.ng-submitted .ng-invalid`.

In this implementation, the directive that sets control status classes on forms and formGroups has its set of statuses widened to include `ng-submitted`. Then, in the event that `is('submitted')` is invoked, the `submitted` property of the control container is returned iff it exists. This is preferred over checking whether the container is a `Form` or `FormGroup` directly to avoid reflecting on those classes.

Closes #30486.

PR Close #42132.

This reverts commit 00b1444d12, undoing the rollback of this change.

PR Close #42132
2021-06-08 14:02:29 -07:00
Pete Bacon Darwin f788e6b8a6 refactor(docs-infra): prepare DocumentService to handle new disambiguated URLs (#42509)
A subsequent commit is going to change disambiguated URLs.
This commit prepares the AIO application to attempt the new URLs
if the old URLs fail. This will help to mitigate problems that may occur
during the period between deployment of the new version and the
service-worker not being updated.

PR Close #42509
2021-06-08 11:45:53 -07:00
Kristiyan Kostadinov afd68e5674 feat(compiler): emit diagnostic for shadow dom components with an invalid selector (#42245)
This is based on a discussion we had a few weeks ago. Currently if a component uses `ViewEncapsulation.ShadowDom` and its selector doesn't meet the requirements for a custom element tag name, a vague error will be thrown at runtime saying something like "Element does not support attachShadowRoot".

These changes add a new diagnostic to the compiler that validates the component selector and gives a better error message during compilation.

PR Close #42245
2021-06-07 10:44:57 -07:00
Jessica Janiuk 00b1444d12 Revert "feat(forms): add `ng-submitted` class to forms that have been submitted." (#42474)
This reverts commit f024d7556081f8913f21761bb8e6aab8d08be110.

PR Close #42474
2021-06-03 17:42:02 -07:00
Dylan Hunn 47270d9e63 feat(forms): add `ng-submitted` class to forms that have been submitted. (#42132)
As previously discussed in pull/31070 and issues/30486, this would be useful because it is often desirable to apply styles to fields that are both `ng-invalid` and `ng-pristine` after the first attempt at form submission, but Angular does not provide any simple way to do this (although evidently Angularjs did). This will now be possible with a descendant selector such as `.ng-submitted .ng-invalid`.

In this implementation, the directive that sets control status classes on forms and formGroups has its set of statuses widened to include `ng-submitted`. Then, in the event that `is('submitted')` is invoked, the `submitted` property of the control container is returned iff it exists. This is preferred over checking whether the container is a `Form` or `FormGroup` directly to avoid reflecting on those classes.

Closes #30486.

PR Close #42132
2021-06-03 13:21:29 -07:00
JoostK 85c7f7691e fix(common): infer correct type when `trackBy` is used in `ngFor` (#41995)
When a `trackBy` function is used that accepts a supertype of the iterated
array's type, the loop variable would undesirably be inferred as the supertype
instead of the array's item type. This commit adds an inferred type parameter
to `TrackByFunction` to allow an extra degree of freedom, enabling the
loop value to be inferred as the most narrow type.

Fixes #40125

PR Close #41995
2021-06-03 11:33:26 -07:00
Andrew Scott 6a2e3e2b2c docs: change Navigation from type to interface (#42281)
Navigation type should be interface so it can be documented on aio site.

fixes #37384

PR Close #42281
2021-06-01 14:13:20 -07:00
AleksanderBodurri cdb8f556fb feat(docs-infra): implement dark mode (#41129)
defines styles for a first iteration of an aio darkmode

PR Close #41129
2021-05-27 11:24:53 -07:00
iRealNirmal 3a6af8e629 fix(platform-browser): update started state on reset (#41608)
This commit fixes the state of variable _started on call of reset method.

Earlier behaviour was on call of `reset()` method we are not setting back
`_started` flag's value to false and it created various issue for end user
which were expecting this behaviour as per name of method.

We provided end user `reset()` method, but it was empty method and on call
of it wasn't doing anything. As end user/developer were not able to
reuse animation not animation after call of reset method.

In this PR on call of `reset()` method we are setting flag `_started` value to false
which can be accessed by `hasStarted()`.

Resolves #18140

PR Close #41608
2021-05-25 20:28:41 +00:00
Pete Bacon Darwin 8e232e6d88 build(docs-infra): show a dist-tag when installing the CLI on non-stable versions (#41991)
It is important to use the correct major version of the Angular CLI when
following the examples in the tutorials. This commit provides a custom
element that renders an appropriate dist-tag in the setup step of
the tutorial when the docs are not in "stable" mode.

Fixes #39821

PR Close #41991
2021-05-10 16:10:33 -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
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
Alan Agius f0696cdcfa test: update `runtime-es2015` sizes follow CLI updates (#41871)
These size changes are caused by a new Webpack version.

PR Close #41871
2021-04-30 14:31:09 -07:00
Kristiyan Kostadinov 6581a1b48d perf(core): minor improvements to listener instructions (#41807)
Makes the following improvements to the listener instructions to make them slightly smaller and more memory-efficient.

1. Removes the default value from the `useCapture` parameter since it generates more code than just castint to `false`.
2. Removes the `useCapture` and `eventTargetResolver` parameters from `ɵɵsyntheticHostListener` since they won't be generated by the compiler, as far as I can tell.
3. Makes it so that we don't have to return a target name from a `GlobalTargetResolver`. This allows us to save on some memory, because we can return a reference to the target without having to wrap it in an object literal.

DEPRECATIONS:
`EventManagerPlugin.getGlobalEventTarget` is now deprecated and won't be called from Ivy code anymore. Global events will go through `addEventListener`.

PR Close #41807
2021-04-30 14:14:00 -07:00
Kristiyan Kostadinov 2dd96e08ae Revert "perf(core): avoid storing LView in __ngContext__ (#41358)" (#41901)
This reverts commit 18b33e79d3.

PR Close #41901
2021-04-30 14:12:52 -07:00
Alan Agius 17ffb7480f build(docs-infra): update angular packages to `12.0.0-rc.0` (#41764)
Update Angular packages to `12.0.0-rc.0`

PR Close #41764
2021-04-28 12:33:20 -07:00
Alan Agius 754e5ba839 build: update angular package to `12.0.0-rc.0` (#41764)
Update Angular packages to `12.0.0-rc.0`

PR Close #41764
2021-04-28 12:33:20 -07:00
Kristiyan Kostadinov 18b33e79d3 perf(core): avoid storing LView in __ngContext__ (#41358)
Currently we save a reference to an `LView` on most DOM nodes created by Angular either by saving
the `LView` directly in the `__ngContext__` or by saving the `LContext` which has a reference to
the `LView`. This can be a problem if the DOM node is retained in memory, because the `LView` has
references to all of the child nodes of the view, as well as other internal data structures.

Previously we tried to resolve the issue by clearing the `__ngContext__` when a node is removed
(see https://github.com/angular/angular/pull/36011), but we decided not to proceeed, because it can
slow down destruction due to a megamorphic write.

These changes aim to address the issue while reducing the performance impact by assigning a unique
ID when an `LView` is created and adding it to `__ngContext__`. All active views are tracked in
a map where their unique ID is used as the key. We don't need to worry about leaks within that map,
because `LView`s are an internal data structure and we have complete control over when they are
created and destroyed.

Fixes #41047.

PR Close #41358
2021-04-26 09:31:41 -07:00
Kristiyan Kostadinov de4fafb818 refactor(core): add single type for injector token (#41580)
Currently we have a lot of places where we repeat the type `Type<T>|AbstractType<T>|InjectionToken<T>` which makes it cumbersome to add another type or to type something else with the same signature.

These changes add a new type that can be used instead.

Fixes #39792.

PR Close #41580
2021-04-22 10:47:12 -07:00
Alan Agius 70425539f7 build(docs-infra): remove view engine related code (#41638)
This is a pre-update to Angular 12 cleanup.

This is not needed for version 12, since applications cannot be built using View Engine.

PR Close #41638
2021-04-16 08:59:37 -07:00
Alan Agius 3e2f09ca88 test: enable `namedChunks` in `cli-hello-world-lazy` integration test (#41636)
This ensure that the name of the lazy chunk remains the same during updates. When not using `namedChunks` the id of the bundle is set to "deterministic", which means that the bundle name changes whenever the bundle is updated.

PR Close #41636
2021-04-15 14:37:26 -07:00
jeripeierSBB a99aa29040 fix(animations): allow animations on elements in the shadow DOM (#40134)
When determining whether to run an animation, the `TransitionAnimationPlayer`
checks to see if a DOM element is attached to the document. This is done by
checking to see if the element is "contained" by the document body node.

Previously, if the element was inside a shadow DOM, the engine would
determine that the element was not attached, even if the shadow DOM's
host was attached to the document. This commit updates the `containsElement()`
method on `AnimationDriver` implementations to also include shadow DOM
elements as being contained if their shadow host element is contained.

Further, when using CSS keyframes to trigger animations, the styling
was always added to the `head` element of the document, even for
animations on elements within a shadow DOM. This meant that those
elements never receive those styles and the animation would not run.
This commit updates the insertion of these styles so that they are added,
to the element's "root node", which is the nearest shadow DOM host, or the
`head` of the document if the element is not in a shadow DOM.

Closes #25672

PR Close #40134
2021-04-15 12:45:52 -07:00
mgechev a07f303708 feat(core): introduce getDirectiveMetadata global debugging utility (#41525)
This commit introduces a global debugging method
`ng.getDirectiveMetadata` which returns the metadata for a directive or
component instance.

PR Close #41525
2021-04-13 16:06:32 -07:00
Alex Rickabaugh c9aa87cec0 fix(compiler-cli): show a more specific error for Ivy NgModules (#41534)
When an Ivy NgModule is imported into a View Engine build, it doesn't have
metadata.json files that describe it as an NgModule, so it appears to VE
builds as a plain, undecorated class. The error message shown in this
situation generic and confusing, since it recommends adding an @NgModule
annotation to a class from a library.

This commit adds special detection into the View Engine compiler to give a
more specific error message when an Ivy NgModule is imported.

PR Close #41534
2021-04-13 07:34:45 -07:00
Alan Agius 528e7d787c test: update CLI integration tests to run only for Ivy (#41434)
In Angular CLI 12, application can only be compiled using Ivy, therefore we shouldn't run these tests when Bazel runs with View Engine context.

PR Close #41434
2021-04-12 16:46:29 -07:00
Alan Agius 852b5e366e build: update `@angular-devkit/build-angular` to use commit SHA (#41434)
This is a temporary workaround until the CLI version containing a fix for the regression caused by deacc74 is available on NPM.

Without this change CLI builds will fail with;
```
angularCompiler.getNextProgram is not a function
```

PR Close #41434
2021-04-12 16:46:29 -07:00
Alan Agius 28f1e1cc16 test: remove `cli-hello-world-lazy-rollup` tests (#41434)
In version 12 of the Angular CLI the `experimentalRollupPass` has been removed.

PR Close #41434
2021-04-12 16:46:29 -07:00
Alan Agius ed7d288364 build: update several dependencies (#41434)
With this change we update several dependencies to avoid Renovate creating a lot of PRs during onboarding. We also remove yarn workspaces as after further analysis these are not needed.

Certain dependencies such as `@octokit/rest`, `remark` and `@babel/*` have not been updated as they require a decent amount of work to update, and it's best to leave them for a seperate PR.

PR Close #41434
2021-04-12 16:46:29 -07:00