Commit graph

29561 commits

Author SHA1 Message Date
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
pBouillon
9423c1901e docs: fix the colspan and colSpan link in the property binding page (#53180)
PR Close #53180
2023-12-01 10:36:53 -08:00
Matthieu Riegler
9f3e64adc9 docs: Error codes should start with a 0. (#53271)
Also adding NG0602 to adev.

PR Close #53271
2023-12-01 10:36:20 -08:00
Andrew Kushnir
82609d471c fix(core): support swapping hydrated views in @for loops (#53274)
This commit fixes an issue where swapping hydrated views was not possible in the new control flow repeater. The problem was caused by the fact that an internal representation of a view had no indication that hydration is completed and further detaching/attaching should work in a regular (non-hydration) mode. This commit adds a logic that resets a pointer to a dehydrated content and we use this as an indication that the view is swtiched to a regular mode.

Resolves #53163.

PR Close #53274
2023-12-01 10:35:36 -08:00
Charles Lyding
5613051a8b fix(compiler): allow TS jsDocParsingMode host option to be programmatically set again (#53292)
When the AOT compiler creates a delegated host for a provided TypeScript CompilerHost,
it delegates functionality back to the original via a series of internal method delegations.
However, unlike other members of the CompilerHost, `jsDocParsingMode` is not a method
and cannot be delegated in this way. Attempting to call bind on the property will result
in a runtime error. Instead, `jsDocParsingMode` is now delegated via get/set accessors.
Additionally, the override of `getSourceFile` now has an updated type signature to reflect
the additional of the `jsDocParsingMode` option for the method.

This is a followup to #53126 which updates the other DelegatingCompilerHost.

PR Close #53292
2023-12-01 10:35:07 -08:00
Jessica Janiuk
aad5e5bd0e fix(migrations): CF Migration add support for ngIf with just a then (#53297)
Prior to this fix, the expectation that anytime then was used, else would always be present. That is not a valid assumption.

fixes: #53287

PR Close #53297
2023-12-01 10:33:53 -08:00
Jessica Janiuk
1c1e8c477b fix(migrations): CF migration - ensure NgIfElse attributes are properly removed (#53298)
the attribute in question was assumed to be at the start of the replaced content, but it could be later, too.

fixes: #53288

PR Close #53298
2023-12-01 10:32:35 -08:00
Jessica Janiuk
2998d482dd fix(migrations): CF Migration - Fix case of aliases on i18n ng-templates preventing removal (#53299)
i18n template removal expected no other attributes to be present, but if a bound ngIf is present with aliases and i18n, that is more than what was expected. Now it should safely remove them appropriately.

fixes: #53289

PR Close #53299
2023-12-01 09:18:31 -08:00
Andrew Kushnir
4b23221b4e fix(core): support hydration for cases when content is re-projected using ng-template (#53304)
This commit fixes an issue with hydration, which happens when a content is projected in a certain way, leaving host elements non-projected, but the child content projected.

The fix is to detect such situations and add extra annotations to help runtime logic locate those elements at the right locations.

Resolves #53276.

PR Close #53304
2023-12-01 09:12:54 -08:00
Andrew Kushnir
77ac4cd324 fix(compiler): generate proper code for nullish coalescing in styling host bindings (#53305)
This commit fixes an issue where having an expression with nullish coalescing in styling host bindings leads to JS errors due to the fact that a declaration for a temporary variable was not included into the generated code.

Resolves #53295.

PR Close #53305
2023-12-01 09:12:20 -08:00
Andrew Scott
1940280d27 fix(router): Ensure canMatch guards run on wildcard routes (#53239)
This commit makes sure that wildcard routes still run the `canMatch`
guards.

Fixes #49949

PR Close #53239
2023-11-30 09:45:40 -08:00
Tomasz Ducin
cb500c7ee5 refactor(devtools): devtools support for maps and symbol description (#53167)
Added 2 tiny improvements:
- instead of "Symbol()", "Symbol(DESCRIPTION)" is displayed
- ECMAScript Maps are distinguished
Additionally:
- PropTypes has been moved to a separate file
- Simple unit tests covering each PropType except for PropType.Unknown

PR Close #53167
2023-11-30 09:45:13 -08:00
Matthieu Riegler
a429167994 fix(devtools): use a shared angular detection code (#51569)
This fixes an issue where an angular app exposes a global `ng` object that is not our `ng`.

fixes #51565

PR Close #51569
2023-11-30 09:40:11 -08:00
AleksanderBodurri
7252ee4162 docs(devtools): write feature descriptions for new DI debugging features in Angular Devtools (#52290)
This commit adds new sections to the devtools aio page for the new DI debugging features in Angular DevTools:

1. Directive dependency inspection
2. Injector hierarchy visualization

PR Close #52290
2023-11-30 09:38:27 -08:00
Alexander Melde
1d6d895cca docs: fix typo in control flow track description (#52849)
as -> are
PR Close #52849
2023-11-30 09:37:38 -08:00
Sylvain DEDIEU
f307b505e2 docs: update http providers example to show the app.config.ts instead of the main.ts (#52848)
The examples of how to provide the http fetch, cookie/header name and disabling XSRF protection now show the app.config.ts file instead of the main.ts file since the cli boostrap application with this architecture.

PR Close #52848
2023-11-30 09:37:05 -08:00
Sasidharan SD
26bdf05622 docs: fix variable name in code comment (#52851)
PR Close #52851
2023-11-30 09:36:36 -08:00
Sasidharan SD
e2265b938b docs: remove repetetive line (#52864)
PR Close #52864
2023-11-30 09:36:10 -08:00
Sai Kumar Kola
7671879ecf docs: fix typo in learn-angular/forms-validation (#52901)
PR Close #52901
2023-11-30 09:35:42 -08:00
Sasidharan SD
982dc5d9d8 docs: fix typo on form tutorial step 18 (#52908)
PR Close #52908
2023-11-30 09:35:14 -08:00
Pridon Tetradze
9c7e2797a8 docs: add missing --no-standalone flag (#52910)
PR Close #52910
2023-11-30 09:34:41 -08:00
Sylvain DEDIEU
3dfd21d8d2 docs: wrong web docs urls for host and host-context (#52966)
Wrong MDN Web Docs URLs for host / host-context on angular.dev

PR Close #52966
2023-11-30 09:34:13 -08:00
Sasidharan SD
702e7905c1 docs: fix minor typos in tutorials (#52970)
PR Close #52970
2023-11-30 09:33:46 -08:00
Isaac Aggrey
dcf14ccc01 docs: fix typo (#53039)
PR Close #53039
2023-11-30 09:33:16 -08:00
Matthieu Riegler
5ad9f216da docs: fix image path for directive overview (#53048)
fixes #53047

PR Close #53048
2023-11-30 09:32:35 -08:00
Sasidharan SD
cdca9ea95a docs: fix angular press kit logo title (#53055)
PR Close #53055
2023-11-30 09:30:04 -08:00
Matthieu Riegler
9640f2bceb docs: fix section title on binding.md (#53072)
fixes #53070

PR Close #53072
2023-11-30 09:29:31 -08:00
Sasidharan SD
d89491d195 docs: fix directives header (#53080)
PR Close #53080
2023-11-30 09:29:06 -08:00
Sasidharan SD
cefeadefbe docs: fix inconsistent example in binding page (#53081)
PR Close #53081
2023-11-30 09:28:34 -08:00
Sasidharan SD
d779578aff docs: update template ref variable with correct link (#53084)
PR Close #53084
2023-11-30 09:28:09 -08:00