390 Commits

Author SHA1 Message Date
George Kalpakas 1b2c67d9fd test(docs-infra): fix e2e test for {@example} dgeni tags (#45551) (#45563)
Previously, the `guide/compoent-style` page was used in e2e tests to
verify the behavior of `{@example}` dgeni tags. However, this guide has
been updated and no longer contains an `{@example}` tag.

This commit switches to using a different page (`api/common/NgIf`) that
does currently contain an `{@example}` tag.

(NOTE: This will also fix the [CI failures][1] in #45501.)

[1]: https://circleci.com/gh/angular/angular/1145424

PR Close #45551

PR Close #45563
2022-04-08 15:55:25 +00:00
JoostK 09f8883826 test: update size golden to account for backport conflict (#45480)
The backport in #45473 introduced a change in payload sizes that is not met on
the 13.3.x branch, this commit corrects this issue.

PR Close #45480
2022-03-30 11:34:10 -07:00
Dylan Hunn 6e45777f01 docs: patch port of #45376 (#45473)
PR Close #45473
2022-03-29 15:36:17 -07:00
Paul Gschwendtner 70006daac4 test: update aio payload size golden to reflect Angular update (#45469)
Updates the AIO payload size goldens to reflect the Angular update
affecting both the `aio` and `aio_local` build (due to CLI devkit
changes affecting both goldens, and the Angular update also affecting
the non-local `aio` build / job).

Patch-port of 6e1fce529a

Aside from AIO, the forms integration test size golden also
needs to be updated. A zonejs change caused the 500 bytes limit
to be exceeded. The change landed in `master` without exceeding,
but exceeded in the `13.3.x` branch (unrelated to the Angular
update). Manually confirmed by diffing the bundles that this change
is the culprit.

https://github.com/angular/angular/commit/c08705899f538bd2d26475c94c2832631c16977b

PR Close #45469
2022-03-29 13:13:08 -07:00
Paul Gschwendtner 63539489da test: update api goldens to reflect api-golden bazel rule change (#45469)
The API golden Bazel rule has changed in the shared dev-infra code. Instead
of putting golden API reports into the golden folder as per their original
location in the NPM package, golden reports are now stored based on the
package exports. This makes it more obvious how entry-points are consumable

As part of this change, since the API golden rule now consutls the NPM package
`exports` field, the `localize/tools` entry-point golden file is now generated.

Previously it wasn't generated due to it not having a secondary entry-point
`package.json` file. Such package json files should not be needed anymore
and will be gone in future APF versions.

PR Close #45469
2022-03-29 13:13:08 -07:00
Paul Gschwendtner 2a437616bb ci: update payload size goldens to reflect zone.js update (#45298)
ZoneJS has been updated as part of the lock file refresh by Renovate. The
polyfills bundle reduced in size by around 4k which is due to some code
simplication in ZoneJS being finally released. This is the commit responsible
for the major reduction (also mentioning the reduction):

https://github.com/angular/angular/commit/0f298a13dbd141e5440d1388b124d03384641efe

PR Close #45298
2022-03-14 09:29:12 -07:00
Paul Gschwendtner 913bbba42b ci: update aio payload size golden to reflect Angular update (#45239)
Similar to 63e9cc7cba, but for the
patch branch where the `aio` job increased in total by ~100b.

New total: 718427 bytes
Before total: 718357 bytes

PR Close #45239
2022-03-03 09:14:08 -08:00
Andrew Kushnir 56ca7d385b perf(common): make NgLocalization token tree-shakable (#45118) (#45226)
This commit updates the `NgLocalization` token to become tree-shakable (vs using a direct reference to that token in the `providers` section of the `CommonModule`). The `NgLocalization` token is used for apps that use i18n and for other apps it would be excluded from the bundle.

PR Close #45118

PR Close #45226
2022-03-02 01:02:54 +00:00
Andrew Kushnir 71ff12c1cc perf(core): make LOCALE_ID and other tokens from ApplicationModule tree-shakable (#45102) (#45222)
The `ApplicationModule` module has a number of tokens declared as non-tree-shakable providers. This commit updates them to make tree-shakable.

PR Close #45102

PR Close #45222
2022-03-01 18:38:18 +00:00
JoostK 1a4b489692 perf(animations): improve algorithm to balance animation namespaces (#45113)
The prior approach would consider all existing namespaces from back to front
to find the one that's the closest ancestor for a given host element. An
expensive `contains` operation was used which needed to traverse all the
way up the document root _for each existing namespace_. This commit implements
an optimization where the closest namespace is found by traversing up from
the host element, avoiding repeated DOM traversal.

Closes #45055

PR Close #45113
2022-02-18 13:44:44 -08:00
Andrew Kushnir cbd23ee0de perf(core): make IterableDiffers and KeyValueDiffers tree-shakable (#45094) (#45115)
This commit removed references to the `IterableDiffers` and `KeyValueDiffers` classes from the `ApplicationModule`, which effectively make them tree-shakable. Both classes have `prov` static field with the right setup, so they'll be properly initialized when referenced.

PR Close #45094

PR Close #45115
2022-02-18 13:43:05 -08:00
Jessica Janiuk 0050b01b62 perf(animations): made errors in the animations package tree shakeable (#45079)
This moves all the error strings into exported functions that can be tree shaken away.

PR Close #45079
2022-02-14 16:13:36 -08:00
Renovate Bot d0b88a6810 build: update angular (#44981) (#45027)
Updates Angular

PR Close #44981

PR Close #45027
2022-02-09 10:18:09 -08:00
iRealNirmal 3919ee37cf refactor(forms): update PatternValidator to inherit AbstractValidatorDirective (#44887)
This commit updates the `PatternValidator` class to inherit `AbstractValidatorDirective` to make it conistent with other validators.

Closes angular#42267

PR Close #44887
2022-02-07 12:07:35 -08:00
Andrew Kushnir 30d1c34384 refactor(core): cleanup DebugNode and DebugElement implementations (#44270)
This commit updates `DebugNode` and `DebugElement` implementaitons to cleanup ViewEngine removal artifacts. There is no need for a separate interface and implementation class, so we can combine them now. This comment also gets rid of `R3` suffixes (denoting Ivy) in helper methods.

PR Close #44270
2022-02-04 10:43:43 -08:00
Andrew Kushnir 2916ac9e1a refactor(core): the RuntimeError class should support more compact syntax (#44783)
This commit refactors the `RuntimeError` class to support a short version of providing error messages:
```
throw new RuntimeError(
  RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
  ngDevMode && 'Injector has already been destroyed.');
```
In prod mode, the second argument becomes `false` andn this commit extends the typings to support that.

This commit also contains a couple places were the `RuntimeError` class is used to demostrate the compact form.

PR Close #44783
2022-02-01 00:15:56 +00:00
Andrew Kushnir 4644886aaf perf(animations): remove no longer needed CssKeyframes classes (#44903) (#44919)
This commit removes CSS keyframes-based code that was used to support animations in old browsers. With IE11 deprecation, all supported browsers have native WebAnimations support, so the old code can be removed. This results in ~7KB decrease of the animations package bundle size, since most of the code was non-tree-shakable.

Closes #44520.

PR Close #44919
2022-01-31 22:46:00 +00:00
arturovt 1aebbf8714 fix(forms): ensure OnPush ancestors are marked dirty when the promise resolves (#44886)
Currently, `ngModel` calls` setValue` after the `resolvedPromise` is resolved.
The promise is resolved _after_ the child template executes. The change detection
is run but `OnPush` views are not updated because they are not marked as dirty.

PR Close #44886
2022-01-31 21:38:39 +00:00
Jessica Janiuk fcc6528159 test(animations): Add bundling size regression test for animations package (#44826)
This adds a size regression test for the animations package to the test suite.

PR Close #44826
2022-01-26 12:54:36 -08:00
Renovate Bot 966343bb92 build: update angular (#44771)
PR Close #44771
2022-01-25 09:24:00 -08:00
iRealNirmal fa7c7afbe9 refactor(forms): update required validator and checkbox validator to inherit abstractValidator (#44162)
Modified required validator and checkbox validator to inherit abstractValidator.

For every validato type different PR will be raised as discussed in #42378.

Closes #42267

PR Close #44162
2022-01-24 14:50:58 -08:00
Kristiyan Kostadinov a4aa9b3c28 Revert "feat(core): allow for injector to be specified when creating an embedded view (#44666)" (#44807)
This reverts commit b49ffcd50e.

PR Close #44807
2022-01-24 12:22:22 -08:00
Kristiyan Kostadinov 40f27a31d2 Revert "feat(common): add injector input to ngTemplateOutlet (#44761)" (#44807)
This reverts commit ed21f5c753.

PR Close #44807
2022-01-24 12:22:22 -08:00
Doug Parker ac2f262e9a docs: add extended diagnostics documentation (#44704)
This includes the initial documentation for extended diagnostics with a page for each of the two initial checks. They follow the same general formula, and hopefully in the future they can be properly generated from metadata rather than copy-pasted as they are currently.

PR Close #44704
2022-01-24 10:41:13 -08:00
Kristiyan Kostadinov ed21f5c753 feat(common): add injector input to ngTemplateOutlet (#44761)
Implements the new `injector` option from #44666 into `ngTemplateOutlet`.

PR Close #44761
2022-01-19 16:47:40 -08:00
Andrew Kushnir 9c11183e74 docs: deprecate CachedResourceLoader and RESOURCE_CACHE_PROVIDER symbols (#44749)
DEPRECATED:

The `CachedResourceLoader` and `RESOURCE_CACHE_PROVIDER` symbols were previously necessary in some cases to test AOT-compiled components with View Engine, but they are no longer needed since Ivy.

PR Close #44749
2022-01-19 09:42:40 -08:00
Andrew Kushnir 9f12e7fea4 docs: deprecate ComponentFactory and ComponentFactoryResolver symbols (#44749)
DEPRECATED:

The `ComponentFactory` and `ComponentFactoryResolver` classes are deprecated. Since Ivy, there is no need to resolve Component factories. Please use other APIs where you Component classes can be used directly (without resolving their factories).

PR Close #44749
2022-01-19 09:42:40 -08:00
Kristiyan Kostadinov b49ffcd50e feat(core): allow for injector to be specified when creating an embedded view (#44666)
Adds support for passing in an optional injector when creating an embedded view through `ViewContainerRef.createEmbeddedView` and `TemplateRef.createEmbeddedView`. The injector allows for the DI behavior to be customized within the specific template.

Fixes #14935.

PR Close #44666
2022-01-19 09:09:38 -08:00
Dylan Hunn fb27867ab8 Revert "refactor(forms): Move FormControl to an overridden exported constructor. (#44316)" (#44750)
This reverts commit cd5200ea68.

PR Close #44750
2022-01-18 19:54:51 -08:00
Ramesh Thiruchelvam bc03a2e3e3 refactor(core): make the error messages tree shakable (#44359)
Long error messages can be tree-shaken in the production build and replaced with error codes.

See: https://github.com/angular/angular/pull/44219#issuecomment-983216374

PR Close #44359
2022-01-18 17:38:10 -08:00
Dylan Hunn cd5200ea68 refactor(forms): Move FormControl to an overridden exported constructor. (#44316)
This implementation change was originally proposed as part of Typed Forms, and will have major consequences for that project as described in the design doc. Submitting it separately will greatly simplify the risk of landing Typed Forms. This change should have no visible impact on normal users of FormControl.

See the Typed Forms design doc here: https://docs.google.com/document/d/1cWuBE-oo5WLtwkLFxbNTiaVQGNk8ipgbekZcKBeyxxo.

PR Close #44316
2022-01-18 14:51:53 -08:00
Ramesh Thiruchelvam 4307b82058 refactor(common): make the error messages tree shakable (#44663)
Make Long error messages tree-shakable in the production build with error codes.

fixes #40096

PR Close #44663
2022-01-18 10:31:44 -08:00
Alan Agius f06b0d9d01 test: update integration payload size checks golden file (#44440)
This updates the size checks for Angular CLI version 13.1.3. The increase in size is due to changes in ESBuild.

Before
```js
class bS extends Wl {
  constructor(t, n, r, i) {
    super(t), (this.component = r);
    const o = Is(i + "-" + r.id, r.styles, []);
    n.addStyles(o),
      (this.contentAttr = "_ngcontent-%COMP%".replace(Gl, i + "-" + r.id)),
      (this.hostAttr = "_nghost-%COMP%".replace(Gl, i + "-" + r.id));
  }
  applyToHost(t) {
    super.setAttribute(t, this.hostAttr, "");
  }
  createElement(t, n) {
    const r = super.createElement(t, n);
    return super.setAttribute(r, this.contentAttr, ""), r;
  }
}
```

Now
```js
class ES extends Wl {
  constructor(t, n, r, i) {
    super(t), (this.component = r);
    const o = Is(i + "-" + r.id, r.styles, []);
    n.addStyles(o),
      (this.contentAttr = (function _S(e) {
        return "_ngcontent-%COMP%".replace(Gl, e);
      })(i + "-" + r.id)),
      (this.hostAttr = (function CS(e) {
        return "_nghost-%COMP%".replace(Gl, e);
      })(i + "-" + r.id));
  }
  applyToHost(t) {
    super.setAttribute(t, this.hostAttr, "");
  }
  createElement(t, n) {
    const r = super.createElement(t, n);
    return super.setAttribute(r, this.contentAttr, ""), r;
  }
}
```

PR Close #44440
2022-01-13 18:30:52 +00:00
Andrew Kushnir 57d0ca18e7 ci: add golden files for runtime error codes (#44677)
Runtime error codes in the Core, Common and Forms packages were not included into the `public-api` group reviews. This commit creates the necessary golden files to keep track of further changes in the runtime codes.

This is a followup from https://github.com/angular/angular/pull/44398#issuecomment-1006910976.

PR Close #44677
2022-01-12 20:42:06 +00:00
iRealNirmal c7b210d484 refactor(forms): update email validator to inherit abstractValidator (#44545)
Modified email validator to inherit abstractValidator.

For every validato type different PR will be raised as discussed in #42378.

Closes #42267

PR Close #44545
2022-01-12 20:41:40 +00:00
Doug Parker 83e6db4081 refactor(compiler-cli): add validation to extended template diagnostics configuration (#44391)
Refs #42966.

This validates the `tsconfig.json` options for extended template diagnostics. It verifies:
* `strictTemplates` must be enabled if `extendedDiagnostics` have any explicit configuration.
* `extendedDiagnostics.defaultCategory` must be a valid `DiagnosticCategoryLabel`.
* `extendedDiagnostics.checks` keys must all be real diagnostics.
* `extendedDiagnostics.checks` values must all be valid `DiagnosticCategoryLabel`s.

These include new error codes, each of which prints out the exact property that was the issue and what the available options are to fix them.

It does disallow the config:

```json
{
  "angularCompilerOptions": {
    "strictTemplates": false,
    "extendedDiagnostics": {
      "defaultCategory": "suppress"
    }
  }
}
```

Such a configuration is technically valid and could be executed, but will be rejected by this verification logic. There isn't much reason to ever do this, since users could just drop `extendedDiagnostics` altogether and get the intended effect. This is unlikely to be a significant issue for users, so it is considered invalid for now to keep the implementation simple.

PR Close #44391
2022-01-11 17:33:16 +00:00
Doug Parker 9e5ac51f69 refactor(compiler-cli): add defaultCategory option (#44391)
Refs #42966.

The `defaultCategory` option is used for any extended template diagnostics which do not have any specific category specified for them. It defaults to `warning`, since that is the most common behavior expected for users. This provides an easy way for users to promote all diagnostics to errors or suppress all diagnostics.

PR Close #44391
2022-01-11 17:33:16 +00:00
Doug Parker 416368a587 refactor(compiler-cli): add initial compiler options definitions for extended template diagnostics (#44391)
Refs #42966.

This includes a mapping of extended template diagnostics to their associated diagnostic category. It is generated from the list of diagnostic names, so the list should always be implicitly kept up to date. Usage looks like:

```json
{
  "angularCompilerOptions": {
    "extendedDiagnostics": {
      "checks": {
        "invalidBananaInBox": "error",
        "nullishCoalescingNotNullable": "suppress"
      }
    }
  }
}
```

PR Close #44391
2022-01-11 17:33:16 +00:00
Doug Parker ed74e3ad61 refactor(compiler-cli): add ExtendedTemplateDiagnosticName and TemplateCheckFactory (#44391)
Refs #42966.

The enum of extended template diagnostic names allows a global registry of first-party diagnostics with a developer-friendly string name which can be used for configuration. This name is used in the new `TemplateCheckFactory` to bind the name to a particular `ErrorCode` and make both available *before* constructing the actual template check, which is necessary to configure it appropriately.

PR Close #44391
2022-01-11 17:33:15 +00:00
Andrew Scott 5a4ddfd4f5 feat(router): Allow symbol keys for Route data and resolve properties (#44519)
This commit adds the ability to use a symbol as the key for the `data` and `resolve` objects
in a `Route` config.

PR Close #44519
2022-01-10 19:43:12 +00:00
JoostK 7052e27677 refactor(compiler-cli): improve DX for reference emit failures (#44587)
In certain scenarios, the compiler may have crashed with an
`Unable to write a reference` error which would be particularly hard
to diagnose. One of the primary reasons for this failure is when the
`rootDir` option is configured---typically the case for libraries---
and a source file is imported using a relative import from an external
entry-point. This would normally report TS6059 for the invalid relative
import, but the crash prevents this error from being surfaced.

This commit refactors the reference emit logic to result in an explicit
`Failure` state with a reason as to why the failure occurred. This state
is then used to report a `FatalDiagnosticException`, preventing a hard
crash.

Closes #44414

PR Close #44587
2022-01-06 23:44:24 +00:00
Andrew Kushnir 67df935b41 refactor(forms): use shared RuntimeError class (#44398)
This commit performs some refactoring of the AbstractControl-based classes to employ shared `RuntimeError` class and also updates the code to avoid duplication and improve minification.

PR Close #44398
2022-01-06 23:43:19 +00:00
Dylan Hunn 5ae1030462 feat(forms): Add an unused symbol AnyForUntypedForms. (#44467)
This symbol will support the typed forms migration in google3. The docs will be updated once the migration begins.

Pertains to #13721.

PR Close #44467
2022-01-04 12:18:26 -08:00
Paul Gschwendtner 3a29c57f60 test: update size goldens to reflect latest CLI devkit update (#44490)
Updates the size goldens to the reflect the latest CLI devkit updates.

PR Close #44490
2022-01-04 12:14:14 -08:00
Kristiyan Kostadinov 7c246d513b fix(docs-infra): update examples to Angular 13.1 (#44487)
Updates AIO and the live examples to 13.1.0 in order to resolve a build error when opened on Stackblitz. They were using TS 4.5 with Angular ~13.0.0 which doesn't support 4.5.

Fixes #44480.

PR Close #44487
2021-12-15 13:22:14 -05:00
Dylan Hunn 72092ebd26 feat(forms): Allow a FormControl to use initial value as default. (#44434)
Allow a FormControl to be reset to its initial value. Provide this feature via a new option in a FormControlOptions interface, based on AbstractControlOptions.

Also, expose the default value as part of the public API. This is part of a feature that has been requested elsewhere (e.g. in #19747).

This was originally proposed as part of typed forms. As discussed in the GDE session (and after with akushnir/alxhub), it is likely better to just reuse the initial value rather than accepting an additional default.

It is desirable to land this separately in order to reduce the scope of the typed forms PR, and make it a types-only change.

Pertains to issue #13721.

PR Close #44434
2021-12-15 10:36:13 -05:00
Renovate Bot 7b6ca4c5d2 build: update angular (#44273)
PR Close #44273
2021-12-10 16:39:05 -05:00
Alex Rickabaugh 0cd524b148 Revert "refactor(forms): Move FormControl to an overridden exported constructor. (#44316)"
This reverts commit cdf50ff931.

Reverting as this needs a little more work on the documentation side, plus
the `export declare interface` syntax in `model.ts` might have unintended
side effects in g3.
2021-12-08 13:36:58 -05:00
Dylan Hunn cdf50ff931 refactor(forms): Move FormControl to an overridden exported constructor. (#44316)
This implementation change was originally proposed as part of Typed Forms, and will have major consequences for that project as described in the design doc. Submitting it separately will greatly simplify the risk of landing Typed Forms. This change should have no visible impact on normal users of FormControl.

See the Typed Forms design doc here: https://docs.google.com/document/d/1cWuBE-oo5WLtwkLFxbNTiaVQGNk8ipgbekZcKBeyxxo.

PR Close #44316
2021-12-08 13:24:28 -05:00
Kristiyan Kostadinov 6df314f3d9 refactor(animations): remove unnecessary code (#44378)
* The `TransitionAnimationEngine` had a fallback where it would store classes directly on a node if it doesn't have a `classList`. Presumably this is to support old browsers or if an animation is set on something like `ng-container`. This information was never used for anything since `containsClass` was never called. These changes simplify the logic to just a null check.
* Deprecates the `AnimationDriver.matchesElement` method, because it was only used in one place which can be replaced with `classList.contains`. We can't remove the method completely, because `AnimationDriver` is a public API. We also can't turn it into a method on the base class in order to remove it from the sub-classes, because it can break apps using `noImplicitOverride` while extending `AnimationDriver`.

PR Close #44378
2021-12-08 13:23:40 -05:00