Commit graph

29561 commits

Author SHA1 Message Date
Tim Bowersox
4948ab9ee5 docs: expand async validators in reactive forms (#44764)
* Hone docregions for code examples
* Add more detailed description

PR Close #44764
2022-01-24 14:53:14 -08:00
Tim Bowersox
2c40b7d250 docs: revise text for adding async validators to template-driven forms (#44764)
Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>
PR Close #44764
2022-01-24 14:53:14 -08:00
Tim Bowersox
765c860795 docs: restore UniqueAlterEgoValidator (#44764)
Update the docregion for the directive class to differentiate them

PR Close #44764
2022-01-24 14:53:14 -08:00
Tim Bowersox
34bbf664b5 docs: fix UniqueAlterEgoValidatorDirective (#44764)
* Use correct class name in providers
* Update parameter & return signature for validate()
PR Close #44764
2022-01-24 14:53:14 -08:00
Tim Bowersox
4098aac093 docs: update async validators section (#44764)
* Update the UniqueAlterEgoValidator code example
* Add async-validator docregion to hero-form-reactive.component.2.ts
* Fix typo under Implementing a custom async validator
* Add h3 sections for adding async validators to reactive & template-driven forms
PR Close #44764
2022-01-24 14:53:14 -08:00
Tim Bowersox
25739c83e2 docs: add note about using NG_ASYNC_VALIDATORS (#44764)
When setting up an async validator in a template-driven form, it's necessary to register the directive with NG_ASYNC_VALIDATORS instead of NG_VALIDATORS. This was not mentioned in the docs.
PR Close #44764
2022-01-24 14:53:14 -08:00
Jessica Janiuk
c9fcc4f617 test(animations): Add bundling symbol test for animations package (#44809)
This adds a full bundling animation symbols test to the test suite.

PR Close #44809
2022-01-24 14:52:30 -08:00
George Kalpakas
ec0a0e0669 feat(service-worker): add cacheOpaqueResponses option for data-groups (#44723)
Add a new option for configuring data-groups, `cacheOpaqueResponses`,
that determines whether opaque responses are cached or not. This allows
greater flexibility in configuring the behavior of data-groups, while
still keeping the current defaults as fallbacks.

Fixes #44246

PR Close #44723
2022-01-24 14:51:59 -08:00
George Kalpakas
bfcc69d8c0 test(service-worker): make MockResponse behave more similarly to real responses (#44723)
Make the `MockResponse` class used in tests behave more similarly to how
real responses work by making the following improvements:
- Use an empty `statusText` (`''`) when provided, instead of the default
  `'OK'` value. This allows better representing opaque responses.
- Preserve more properties (`redirected`, `type`, `url`) when cloning a
  `MockResponse`.

PR Close #44723
2022-01-24 14:51:58 -08:00
George Kalpakas
2f1457d12f docs(service-worker): mention strategy-dependent caching behavior for opaque responses (#44723)
Update the "Service worker configuration" guide to mention the different
caching behaviors used for opaque responses based on the data-group's
configured strategy.

Related to #44246.

PR Close #44723
2022-01-24 14:51:58 -08:00
iRealNirmal
531d1cf9a3 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:57 -08:00
Kristiyan Kostadinov
a534a78e67 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
7de8ee960d 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
Kristiyan Kostadinov
215db7fbe6 fix(core): error if NgZone.isInAngularZone is called with a noop zone (#44800)
When the user opts into the noop `NgZone`, they usually still interact with the static methods on the non-noop class. This change adds a check to handle the case where zone.js hasn't been loaded.

Fixes #44784.

PR Close #44800
2022-01-24 10:44:43 -08:00
Wiley Marques
8363db4189 docs(router): fixing pathMatch doc to style code correctly (#44796)
PR Close #44796
2022-01-24 10:42:51 -08:00
Andrew Scott
ec2e6f6a3f fix(compiler): correct spans when parsing bindings with comments (#44785)
The previous fix for correcting spans with comments in
59eef29a6c
had the unfortunate side effect of _breaking_ the spans with comments
when there was leading whitespace. This happened because the previous
fix was testing one without a comment, identifying that the offset shouldn't
have anything added to it, and then removing that offset adjustment
(`offsets[i] + (expressionText.length - sourceToLex.length)`).

Upon further investigation, this offset adjustment _was actually
necessary_ for when the input had comments, but this was only because
the `stripComments` function used `trim` to remove whitespace for these
cases. This is the real problem -- not only does it create a ton of confusion
but also it means that the behavior of the lexer and resulting spans is
different between inputs with comments and inputs without comments.

After reviewing how the `inputLength` of `_ParseAST` was used, it
appears that the correct behavior would be to _not_ trim the input. The
`inputLength` is used to advance the current index beyond points which
have been processed. This _should_ include any whitespace. Additionally,
`inputLength` doesn't appear to be needed at all. When there was no
comment in the input, it was always equal to the `input.length` anyways.
When there _is_ a comment, it should include that comment anyways to
advance the index beyond the comment.

PR Close #44785
2022-01-24 10:41:53 -08:00
Andrew Scott
f1e84a3cef fix(compiler-cli): properly index <svg> elements when on a template (#44785)
The original fix for svg elements in
92b23f4851
did not account for svg elements when they also had a structural
directive on them, making the node a template. This resulted in the
logic added in fix above not being applied.

PR Close #44785
2022-01-24 10:41:53 -08:00
Doug Parker
33f23abe1d 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
George Kalpakas
7480660a95 fix(docs-infra): track error docs during serve-and-sync (#44704)
Refs #42966.

Look for changes in error docs (i.e. docs under `aio/content/error/`) in
`authors-package`, so that such docs are tracked when running the
`serve-and-sync` script.

PR Close #44704
2022-01-24 10:41:13 -08:00
George Kalpakas
b19c3f7e71 fix(docs-infra): track error docs during serve-and-sync (#44704)
Refs #42966.

Look for changes in error docs (i.e. docs under `aio/content/error/`) in
`authors-package`, so that such docs are tracked when running the
`serve-and-sync` script.

PR Close #44704
2022-01-24 10:41:13 -08:00
JiaLiPassion
25a83eb264 fix(zone.js): update several flaky cases (#41526)
Related to #41434

Fix several flaky cases.

1. should restore `window.onerror` in test cases.
2. expect().toThrow() should pass a function.

PR Close #41526
2022-01-24 10:40:42 -08:00
Andrew Kushnir
955a677aab
docs: release notes for the v13.2.0-rc.1 release (#44805) 2022-01-24 09:50:02 -08:00
Oleg Postoev
80467c3aa5 refactor(common): unused return value from attemptFocus (#44457)
The function attemptFocus had a return value that nowhere is used. But it still saves in the bundle.

PR Close #44457
2022-01-21 13:11:30 -08:00
JoostK
627e807eb8 fix(compiler): properly compile DI factories when coverage reporting is enabled (#44732)
When running tests with code coverage using Istanbul, the code is
instrumented with coverage reporting statements. These statements are
also inserted into synthesized constructors, preventing Angular from
properly recognizing them as synthesized constructor.

This commit changes the regex to detect synthesized constructors to allow
for statements within the constructor before the `super(...arguments);`
call. This is limited to code that does not contain a `}`, but this
is sufficient to support Istanbul's coverage instrumentation statements.

The tests have been extended with an input file that is being
instrumented using `babel-plugin-istanbul` for both ES2015 and ES5
targets, in order to verify that the approach works for real-world
usages.

Fixes #31337

PR Close #44732
2022-01-21 13:10:42 -08:00
Renovate Bot
e2920d98aa build: update all non-major dependencies (#44713)
PR Close #44713
2022-01-21 11:21:51 -08:00
Douglas Parker
d8bff1a1b3 fix(compiler-cli): skip ExtendedTemplateCheckerImpl construction if there were configuration errors (#44778)
Previously, if a bad extended diagnostic category was given, it would fail with the expected error as well as an unexpected assertion error:

```
$ ng build -c development
✔ Browser application bundle generation complete.

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Unexpected call to 'assertNever()' with value:
test
    at /home/douglasparker/Source/ng-new/node_modules/@ngtools/webpack/src/ivy/loader.js:77:18
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Unexpected call to 'assertNever()' with value:
test
    at /home/douglasparker/Source/ng-new/node_modules/@ngtools/webpack/src/ivy/loader.js:77:18
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Error: error NG4004: Angular compiler option "extendedDiagnostics.checks['invalidBananaInBox']" has an unknown diagnostic category: "test".

Allowed diagnostic categories are:
warning
error
suppress
```

The assertion comes from `ExtendedTemplateCheckerImpl`, which expects a well-formed configuration, yet the compiler would construct it even when errors were found. This commit skips constructing and running extended diagnostics if the configuration had errors, which should avoid triggering these assertion errors.

I'm unfortunately not able to actually test this change. The test passes even before the fix because the `ngc` binary and end-to-end tests [don't request diagnostics unless the configuration is considered valid](ed21f5c753/packages/compiler-cli/src/perform_compile.ts (L292-L293)). See [Slack](https://angular-team.slack.com/archives/C4WHZQMRA/p1642641305003800) for more details.

PR Close #44778
2022-01-21 11:20:48 -08:00
Andrew Scott
fb9163ae50 fix(core): consistently use namespace short name rather than URI (#44766)
`Renderer2` APIs expect to be called with the namespace name rather than
the namespace URI. Rather than passing around the URI and having to
account for different calling contexts, this change consistently uses
the namespace short names.

Importantly, the URI was only used in `component_ref.ts` `create`
(because `getNamespace returned the URIs`) and `createElementNode` in
`node_manipulation.ts` (because `getNamespaceUri` also used the URIs).
In contrast, attributes would use the _short names instead of URIs_
(see `setUpAttributes` in `attrs_utils.ts`). These names are pulled
directly from the attribute, i.e. `xhtml:href` and not converted to URI.
This dichotomy is confusing and unnecessary. The change here aligns the two
approaches in order to provide consistently throughout the system.

This relates to #44766 because the `createElementNode` was calling the
`AnimationRenderer.createElement` which delegates to the
`ServerRenderer`, which in turn was only set up to expect short names.
As a result, the `NAMESPACE_URIS` lookup failed and `Domino` created
the `svg` as a regular `Element` which does not have a `styles`
property.

resolves #44766

PR Close #44766
2022-01-21 11:19:30 -08:00
Andrew Scott
37e5196d38 test: Update test to not declare component in multiple modules (#44766)
When running locally, these integration tests appear to fail because the
component is declared in many test modules.

PR Close #44766
2022-01-21 11:19:30 -08:00
ivanwonder
9d4af65e34 feat(language-service): Provide plugin to delegate rename requests to Angular (#44696)
When the user wants to rename a symbol in the ts file VSCode
will ask the rename providers for the answer in turn. If the
first extension returns the result, the VSCode will break the
loop and apply the result. If the first extension cannot rename
the symbol, VSCode will ask the second extension in the
list (built-in TS/JS extension, Angular LS extension, etc.).
In other words, VSCode takes the result from only one rename provider
and the order depends on registration timing, scoring.

Because the built-in ts extension and Angular extension have the
same high score, if the built-in ts extension is the
first(depends on the time the extension was registered), the result
will be provided by the built-in extension. We want Angular to
provide it, so this plugin will delegate rename requests and reject
the request for the built-in ts server.

The Angular LS only provides the rename info when working within
an Angular project. If we cannot locate Angular sources in the
project files, the built-in extension should provide the rename info.

This plugin will apply to the built-in TS/JS extension and delegate
rename requests to the Angular LS. It provides the rename info only
when it is an Angular project. Otherwise, it will return info by the
default built-in ts server rename provider.

See [here][1] for more info.

[1]: https://github.com/microsoft/vscode/issues/115354

PR Close #44696
2022-01-21 11:18:48 -08:00
Doug Parker
197f3f4a26 fix(compiler-cli): remove leftover _extendedTemplateDiagnostics requirements (#44777)
Refs #42966.

There were two remaining places where `_extendedTemplateDiagnostics` needed to be set which should have been removed in #44712 but got missed. This updates them to only require `strictTemplates` and not `_extendedTemplateDiagnostics` so the feature is properly enabled in production.

PR Close #44777
2022-01-20 14:03:46 -08:00
Martin Probst
4e180cb43b refactor(compiler): pass rootDir to tsickle (#44768)
tsickle's underlying API has changed to require passing a rootDir to getGeneratedExterns.
PR Close #44768
2022-01-20 11:16:35 -08:00
Stephanie Tuerk
011d0f27b8 docs: correct (possible) typo (#44759)
change 'reference' to 'referencing' -- I believe this is is a typo and that this is the proper correction.
PR Close #44759
2022-01-20 09:22:35 -08:00
Dylan Hunn
3c14eb559f docs: release notes for the v13.2.0-rc.0 release 2022-01-19 17:43:26 -08:00
Dylan Hunn
ed6911e08c release: bump the next branch to v13.3.0-next.0 2022-01-19 17:43:26 -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
Derek Cormier
ec1057014b fix(docs-infra): fix date parsing in a flaky test (#44763)
Mock dates in EventsComponent tests are parsed in inconsistent ways
across platforms/browsers, which makes the comparison to the mocked
UTC "now" date behave differently causing the test to fail. This fix
ensures that the mocked "now" date is parsed in the same way as the
test dates to avoid inconsistencies.

PR Close #44763
2022-01-19 16:47:16 -08:00
Doug Parker
fa835b5a29 feat(compiler-cli): enable extended diagnostics by default (#44712)
Refs #42966.

Extended diagnostics provide additional analysis about Angular templates by emitting warnings for specific patterns known to be error prone or cause developer confusion. Currently, there are two such diagnostics which are enabled by default:

* `invalidBananaInBox` emits a warning if a user writes a two-way binding backwards like `([foo])="bar"`, when they actually wanted `[(foo)]="bar"`.
* `nullishCoalescingNotNullable` emits a warning if a binding attempts to perform nullish coalescing (`??`) on a type which does not include `null` or `undefined`, such as `{{ foo ?? 'bar' }}` where `foo` is defined as `string` instead of `string | null`.

These diagnostics are enabled as warnings by default, but this can be configured in the `tsconfig.json` like so:

```jsonc
{
  "angularCompilerOptions": {
    "extendedDiagnostics": {
      // The categories to use for specific diagnostics.
      "checks": {
        // Maps check name to its category.
        "invalidBananaInBox": "suppress"
      },

      // The category to use for any diagnostics not listed in `checks` above.
      "defaultCategory": "error"
    }
  }
}
```

Allowed categories for a diagnostic are `warning` (default), `error`, or `suppress`. `warning` emits the diagnostic but allows the compilation to succeed, `error` *will* fail the compilation, while `suppress` will ignore the diagnostic altogether.

The initial release has two diagnostics, and we are hoping to expand this longer term to add more diagnostics and provide additional insight into Angular templates to detect and surface developer mistakes *before* hours of debugging are wasted.

PR Close #44712
2022-01-19 09:58:37 -08:00
Andrew Kushnir
4e95a316ce docs: deprecate unused config options from the CompilerOptions interface (#44749)
DEPRECATED:

Since Ivy, the CompilerOptions.useJit and CompilerOptions.missingTranslation config options are unused, passing them has no effect.

PR Close #44749
2022-01-19 09:42: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
Dylan Hunn
2b01e17505 docs: release notes for the v13.1.3 release (#44758)
PR Close #44758
2022-01-19 09:40:37 -08:00
Yousaf Nawaz
34d2292323 docs: update deprecated form of the tap operator in http example (#44738)
update deprecated form of the tap operator. Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments

DEPRECATED: tap operator subscribe signature is deprecated

Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments

Closes #44708

PR Close #44738
2022-01-19 09:22:02 -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
41b8ecc9b8 refactor(forms): Make a couple small cleanups encountered while rebasing typed forms. (#44748)
These should all be no-ops publicly; they are just small issues encountered during a large rebase to bring typed-forms current.

PR Close #44748
2022-01-18 16:20:21 -08:00
dario-piotrowicz
ece530faf5 refactor(animations): change errors type from any to string (#44726)
errors in the animations code are of type `any` but are consistently
used as if there were `string`s, change `any` to `string` to make
typing more accurate

PR Close #44726
2022-01-18 15:52:05 -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
JoostK
1f6249dae8 refactor(compiler): remove directive matching from template compiler (#44731)
The directive matching pass that happens during template compilation is
redundant, since directive matching has already happened during the resolution
phase of ngtsc and only matching declarables are provided to the template
compiler. In JIT mode the declarables only become available after the primary
template compilation has completed, so there is no need to perform directive
matching in both JIT and AOT mode.

PR Close #44731
2022-01-18 14:51:08 -08:00
JoostK
dac0430efd refactor(compiler): store modifiers in a bitmask instead of an array (#44731)
This commit slightly reduces memory usage of output AST by storing type
and statement modifiers as a bitmask instead of using an array.

PR Close #44731
2022-01-18 14:51:08 -08:00