Commit graph

28740 commits

Author SHA1 Message Date
Kristiyan Kostadinov
e620b3a724 fix(compiler-cli): add compiler option to disable control flow content projection diagnostic (#53311)
These changes add an option to the `extendedDiagnostics` field that allows the check from #53190 to be disabled. This is a follow-up based on a recent discussion.

PR Close #53311
2023-12-05 17:21:16 -08:00
Matthieu Riegler
8195be1e09 refactor(devtools): run control flow migration. (#53353)
Let's update the devtools with the latest improvements !

PR Close #53353
2023-12-05 17:20:09 -08:00
Jessica Janiuk
01b18a4248 fix(migrations): handle templates outside of component in cf migration (#53368)
If a template is passed in as an input, the ng-template will not exist in the same component template. This will leave a template placeholder behind. This fix ensures that template placeholder gets turned into a template outlet.

fixes: #53361

PR Close #53368
2023-12-05 17:19:37 -08:00
Jessica Janiuk
5a0ed28c9d fix(migrations): handle nested ng-template replacement safely in CF migration (#53368)
When there are ng-templates nested inside other ng-templates, the replacement and removal of the templates gets disrupted. Re-processing the templates in the file along the way resolves this issue.

fixes: #53362

PR Close #53368
2023-12-05 17:19:36 -08:00
Dylan Hunn
05f9c7bd31 refactor(compiler): Initial support for i18n attributes (#53341)
Add support for i18n attributes:
- Generate i18n contexts from i18n attributes, and extract the eventual messages into the constant pool.
- Emit I18nAttributes config instructions when needed.
- Use the generated i18n variable in the appropriate places, including extracted attribute instructions, as well as I18nAttributes config arrays.

PR Close #53341
2023-12-05 17:13:58 -08:00
Matthieu Riegler
6cd91c675c refactor(devtools): enables typescript strict option (#53340)
Enabling `strict` is part of an effort to improve the quality of the devtools code base.
One of the direct side effect is to enable `noImplicitAny`, `strictPropertyInitialization` and `strictBindCallApply`.

This commit also replaces `fullTemplateTypeCheck` with `stringTemplates`.

PR Close #53340
2023-12-05 12:42:56 -08:00
Srinath Vayalpati
1e3bcfecba docs: fixed wrong template string placeholder (#53286)
PR Close #53286
2023-12-04 21:50:35 -08:00
Andrew Scott
50d7916278 feat(router): Add router configuration to resolve navigation promise on error (#48910)
With the deprecation of the configurable errorHandler in the Router, there is a missing
use-case to prevent the navigation promise from rejecting on an error. This rejection
results in unhandled promise rejections. This commit allows developers to instruct
the router to instead resolve the navigation promise with 'false', which matches
the behavior of other failed navigations.

Resolving the Promise would be the ideal default behavior. It is rare
that any code handles the navigation Promise at all and even more rare
that the Promise rejection is caught. Updating the default value for
this option should be considered for an upcoming major version.

fixes #48902

PR Close #48910
2023-12-04 21:49:35 -08:00
Joey Perrott
65cc8befbb build: set up markdown pipeline for the reference section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:10 -08:00
Joey Perrott
631da1dbb0 build: set up markdown pipeline for the tools section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:10 -08:00
Joey Perrott
df13433035 build: set up markdown pipeline for service-workers section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:10 -08:00
Joey Perrott
97e6e04611 build: set up markdown pipeline for runtime-performance part of the best-practices section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:10 -08:00
Joey Perrott
3c9b6cba9f build: set up markdown pipeline for best-practices section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:10 -08:00
Joey Perrott
ae5fe6cc16 build: set up markdown pipeline for introduction section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
c5afa37310 build: set up markdown pipeline for essentials of the introduction section (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
551af0770f build: set up markdown pipeline for testing directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
ecd44b1e10 build: set up markdown pipeline for templates directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
0c60dd39cb build: set up markdown pipeline for signals directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
d8deb4080b build: set up markdown pipeline for pipes directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
37de3f10fc build: set up markdown pipeline for routing directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:09 -08:00
Joey Perrott
2b9eb9d6e5 build: set up markdown pipeline for ngmodules directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:08 -08:00
Joey Perrott
f6691069b1 build: set up markdown pipeline for i18n directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:08 -08:00
Joey Perrott
f35871f6c6 build: set up markdown pipeline for http directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:08 -08:00
Joey Perrott
e582d60f36 build: set up markdown pipeline for forms directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:08 -08:00
Joey Perrott
289f76f569 build: set up markdown pipeline for directives directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:08 -08:00
Joey Perrott
f5e4fe3f62 build: set up markdown pipeline for di directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:08 -08:00
Joey Perrott
f01ff416ce build: set up markdown pipeline for components directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:07 -08:00
Joey Perrott
6594b4311f build: fix name for animations markdown target (#53290)
Use the animations name as the target name instead of test

PR Close #53290
2023-12-04 21:47:07 -08:00
Joey Perrott
4e5c56eda0 build: set up markdown pipeline for root directory of the content guide (#53290)
Set up the markdown pipeline to include the required source files.

PR Close #53290
2023-12-04 21:47:07 -08:00
Kristiyan Kostadinov
d7a83f9521 fix(compiler-cli): avoid conflicts with built-in global variables in for loop blocks (#53319)
Currently we generate the following TCB for a `@for` loop:

```ts
// @for (item of items; track item) {...}

for (const item of this.items) {
  var _t1 = item;
  // Do things with `_t1`
}
```

This is problematic if the item name is the same as a global variable (e.g. `document`), because when the TCB has references to that variable (e.g. `document.createElement`), it'll find the loop initializer instead of the global variable.

These changes fix the issue by generating the following instead:

```ts
for (const _t1 of this.items) {
  // Do things with `_t1`
}
```

Fixes #53293.

PR Close #53319
2023-12-04 21:45:17 -08:00
Andrew Kushnir
596b43d631 refactor(core): skip disconnected nodes while computing node path for hydration (#53317)
In certain cases Angular hydration logic can not rely on the order in which elements are present in a template (for example, in content-projection use-cases) and there is a need to serialize a path from one node to another, so that hydration can locate an element on a page. The logic attempts to use an immediate parent element as an anchor and compute the path from it. If it fails - the path is computed starting from the <body> (this is a fallback).

This commit updates the logic to walk up the parents tree if an immediate parent (from a template) is disconnected from the DOM. This helps to shorten the lookup path and make it more stable.

PR Close #53317
2023-12-04 21:44:08 -08:00
Tomasz Ducin
ba8dc2843a refactor(devtools): filtering providers by token within "injector tree" tab (#53313)
In some injectors, there are LOTS of providers, making it slightly inconvenient to search for a certain one. This commit introduces a search-by-token for providers of a specific injector.

PR Close #53313
2023-12-04 21:43:34 -08:00
Jessica Janiuk
6f75471307 fix(migrations): CF Migration fix missing alias for bound ngifs (#53296)
Empty aliases are considered the item in an ngFor, and ngIf was skipping that value.

fixes: #53291

PR Close #53296
2023-12-04 21:42:57 -08:00
Andrew Kushnir
f245aba782 refactor(core): output an error guide link in prod mode (#53324)
Currently, the link to an error guide is only included into an error message in dev mode. This change makes the `Find more at https://angular.io/errors/NG0XYZ` appear in the error message even in prod mode. Note: the rest of the error message is still tree-shaken away in prod mode (as it happens today).

PR Close #53324
2023-12-04 21:42:28 -08:00
Jessica Janiuk
9834fd2738 fix(migrations): remove setting that removes comments in CF migration (#53350)
This setting was added to prevent comment duplication, since the TS AST printer includes prior line comments as part of a given line with no way to really avoid that.
However in component imports, it is not safe to remove comments as they could be load bearing for some.

PR Close #53350
2023-12-04 21:41:41 -08:00
JoostK
77939a3bd3 fix(core): cleanup signal consumers for all views (#53351)
This commit fixes a memory leak where signal consumers would not be cleaned up for
descendant views when a view is destroyed, because the cleanup logic was only invoked
for the view that is itself being destroyed.

PR Close #53351
2023-12-04 21:41:12 -08:00
Miles Malerba
12dfa9ba13 test(compiler): Update golden partial file (#53327)
Update the golden partial file to include the newly added tests in this
PR.

PR Close #53327
2023-12-04 14:24:21 -08:00
Miles Malerba
4099bd0de6 refactor(compiler): Fix structural directive i18n placeholders (#53327)
Previously we recorded separate param values for a strucural directive
and the element tag it goes on. We then later attempted to combine those
into a single value. However in some cases this merging logic matched
the directive with the wrong tag.

This change implements an alternate approach where we match the
directive to its element tag from the start, while we're traversing the
ops. This should be a more robust solution.

PR Close #53327
2023-12-04 14:24:21 -08:00
Miles Malerba
9a0bf516c3 refactor(compiler): Add missing projection arguments (#53327)
We previously failed to populate the attributes property on projection
ops, this commit populates it and later strips out the "select"
attribute.

PR Close #53327
2023-12-04 14:24:21 -08:00
Miles Malerba
c555120d48 refactor(compiler): Add support for ng-content in i18n blocks (#53327)
Adds support for handling i18n paceholders on ng-content and adds a new
test to verify behavior.

PR Close #53327
2023-12-04 14:24:20 -08:00
Miles Malerba
0a1611d4cc refactor(compiler): Fix sub-template index for sibling i18n blocks (#53327)
Previously we failed to reset the sub-template index counter when we
exited a root block. This caused following sibling blocks to start
counting at the wrong index.

PR Close #53327
2023-12-04 14:24:20 -08:00
Miles Malerba
1baf26f589 refactor(compiler): Fix not expressions (#53327)
Adds `PrefixNot` to the handled expressions in the template pipeline

PR Close #53327
2023-12-04 14:24:20 -08:00
Dylan Hunn
d4b4236902 Revert "fix(router): Ensure canMatch guards run on wildcard routes (#53239)" (#53339)
This reverts commit 1940280d27.

PR Close #53339
2023-12-03 14:57:54 -08:00
Miles Malerba
acd6100960 docs(compiler): Improve code comments (#53300)
Adds better comments describing the case where we have multiple ICU
sub-messages that share the same plaeholder.

PR Close #53300
2023-12-01 14:51:29 -08:00
Miles Malerba
9bd9065410 test(compiler): Enable newly passing tests (#53300)
Enables additional tests that pass after implementing the ICU logic.

PR Close #53300
2023-12-01 14:51:29 -08:00
Miles Malerba
8c34ad5d86 refactor(compiler): Fix ingestion of nested ICUs (#53300)
It is possible for ICUs to be nested inside other ICUs. This change
adjusts our ingestion logic to create extra interpolation ops for the
nested ICUs during ingestion.

PR Close #53300
2023-12-01 14:51:29 -08:00
Miles Malerba
2b3f06a8db refactor(compiler): Remove invalid assertion about i18n params (#53300)
We previously had an assertion that every placeholder in the i18n AST
had a corresponding param in the output. However, there are some cases
such as interpolations nested inside ICUs where this assertion is not
true. This change simply removes the asserion.

PR Close #53300
2023-12-01 14:51:29 -08:00
Miles Malerba
e23752c184 refactor(compiler): Add support for ICUs that share a placeholder (#53300)
ICUs may share a placeholder, and in that case they need special
post-processing. This change adds logic to cover this possibility. In
particular, we set the param to a special placeholder value and then
pass an array containing the sub-message variables as a post-processing
param.

PR Close #53300
2023-12-01 14:51:28 -08:00
Miles Malerba
4afa5ac2f9 refactor(compiler): Handle i18n placeholders with spaces (#53300)
I18n placeholders may contain spaces, this change updates the formatting
logic to replace them with underscores in the output.

PR Close #53300
2023-12-01 14:51:28 -08:00
Miles Malerba
a9fb5fa458 refactor(compiler): Put i18n expression ops in the correct order (#53300)
When we re-assign the slot dependencies for the i18nExprs, we should
move them down below the other ops that target their same slot. This
keeps the behavior consistent with TDB

PR Close #53300
2023-12-01 14:51:28 -08:00