28840 Commits

Author SHA1 Message Date
Dylan Hunn 24177e973b refactor(compiler): Keep a TemplateKind on various binding ops (#53405)
Previously, binding ops only knew whether they applied to a structural template (and even this was actually very misleading!).

Now, binding ops have full information about what kind of template they apply to, if any (e.g. plain template, structural template, etc). Additionally, each binding knows whether it `IsStructuralTemplateAttribute`, which is a property of the binding rather than the template target.

In the future, we should refactor this to unify the various flags that can describe binding types, as well as the flags that describe template targets, into a single and comprehensive field on binding ops.

PR Close #53405
2023-12-08 09:37:56 -08:00
Dylan Hunn 16b7fcaafd refactor(compiler): Move the creation of i18n attribute contexts into a phase (#53405)
Previously, we created i18n contexts for i18n attributes in ingest. This turned out to be the wrong approach, because we don't always want to produce i18n messages for all i18n attributes! In fact, several kinds of i18n attributes on elements with structural directives should not produce their own messages.

This commit also contains related refactors to fix one such structural directives test.

PR Close #53405
2023-12-08 09:37:56 -08:00
Dylan Hunn fd54911521 refactor(compiler): Don't create i18n context ops for attribute bindings on structural templates (#53405)
When a binding is present on an element with a structural directive, that binding is parsed onto *both* the synthetic `ng-template`, as well as the inner element. However, we do not want to create different i18n messages for both bindings; we only want to generate a new i18n message for the inner, "real" element.

PR Close #53405
2023-12-08 09:37:56 -08:00
Dylan Hunn 19daa075e8 refactor(compiler): Listeners should be ingested before i18nStart (#53405)
Listener instructions should not be inside the i18n block. In order to avoid this, we ingest bindings on an element before starting the i18n block.

We previously missed this case because almost all bindings result in *update* instructions, which don't need to be ordered relative to i18nStart/i18nEnd create instructions. However, listeners are the only kind of binding that gets ingested into the create block.

PR Close #53405
2023-12-08 09:37:56 -08:00
Dylan Hunn 3c12cd7ab0 refactor(compiler): Fix i18nExp moving phase in Template Pipeline (#53405)
Previously, our i18n slot moving process was buggy. Specifically, it was not resilient to cases in which a create op consumed a slot, but no update ops depended on that slot.

The new algorithm fixes this issue, and is also easier to understand.

PR Close #53405
2023-12-08 09:37:56 -08:00
Pawel Kozlowski 17dbf8b8e2 fix(core): remove signal equality check short-circuit (#53446)
The PR https://github.com/angular/angular/pull/52465 introduced short-circuit for
the signal equality invocation - with the reasoning that the equality function
should never return false for arguments with the same references. In practice it
turned out that it is rather surprising and the subsequent PR
https://github.com/angular/angular/pull/52532 added a warning when the short-circuit
was taking priority over the equality function.

Still, the presence of the short-circuit prevents people from mutating objects in
place and based on https://github.com/angular/angular/issues/52735 this is a common
and desired scenario. This change removes the short-circuit altogether and thus
fixes the mentioned issue.

We do recognize that removing short-circuit exposes developers to the potentially
surprising logic where mutated in-place change won't be propagated throug the
reactivity graph (due to the deault equality function). But we assume that this might
be less surprising / more desirable as compared to the short-circuit logic.

Fixes #52735

PR Close #53446
2023-12-08 07:05:35 -08:00
Andrew Scott 58ed76be93 fix(core): Avoid refreshing a host view twice when using transplanted views (#53021)
This change fixes and issue where the expectation was that change
detection always goes through `detectChangesInView`. In reality,
`detectChangesInternal` directly calls `refreshView`
and refreshes a view directly without checking if it was dirty (to my discontent).

This update changes the implementation of `detectChangesInternal` to
actually be "detect changes" not "force refresh of root view and detect
changes". In addition, it adds the refresh flag to APIs that were
previously calling `detectChangesInternal` so we get the same behavior
as before (host view is forced to refresh).

Note that the use of `RefreshView` instead of `Dirty` is _intentional_
here. The `RefreshView` flag is cleared before refreshing the view while
the `Dirty` flag is cleared at the very end. Using the `Dirty` flag
could have consequences because it is a more long-lasting change to the
view flags. Because `detectChangesInView` will immediately clear the
`RefreshView` flag, this change is much more limited and does not
result in a different set of flags during the view refresh.

PR Close #53021
2023-12-07 12:05:24 -08:00
Jessica Janiuk 543df3dca5 fix(migrations): ensure we do not overwrite prior template replacements in migration (#53393)
This fixes a bug where only the last replacement of a template placeholder would apply.

fixes: #53383

PR Close #53393
2023-12-07 09:36:03 -08:00
Andrew Scott 65f9115d45 refactor(core): Run ComponentFixture constructor in injection context (#53400)
The component fixture dependencies have to be passed in manually. This
is a bit annoying to manage as we expand which dependencies are needed.
Instead, we can run the constructor in the TestBed injection context and
move the dependencies into the component fixture code, as is done with
other constructors in Angular.

PR Close #53400
2023-12-07 09:35:25 -08:00
Dylan Hunn 049e4ab596 release: cut the v17.0.6 release 17.0.6 2023-12-06 10:15:26 -08:00
Jessica Janiuk e8d01f995b refactor(migrations): Update comments to be more accurate (#53396)
This comment change better clarifies what these regexes do which should alleviate future confusion.

PR Close #53396
2023-12-06 09:45:44 -08:00
Andrew Scott c509ba43f1 Revert "Revert "fix(router): Ensure canMatch guards run on wildcard routes (#53239)" (#53339)" (#53342)
This reverts commit ac8eb5b943.

PR Close #53342
2023-12-06 09:44:19 -08:00
Dylan Hunn aaf199f282 refactor(compiler): Support unary ops in template pipeline (#53376)
Template Pipeline can now ingest and emit unary ops, such as `+` and `-`.

PR Close #53376
2023-12-06 09:43:36 -08:00
Dylan Hunn 648edaa508 refactor(compiler): template pipeline support for i18n blocks (#53376)
Blocks can contain i18n expressions. We already have most of the logic to make them work; we were just missing some ingestion code.

PR Close #53376
2023-12-06 09:43:36 -08:00
Dylan Hunn 755356c1bc refactor(compiler): Separate ownership and target for i18n expressions, and various refactors (#53376)
I18n expressions logically have both a target and an owner:
- For i18n text expressions, the owner is the i18nStart instruction. The target is initially the same, but later moves to be the last slot consumer in the i18n block.
- For i18n attribute expressions, the owner is the I18nAttributes config instruction, whereas the target is the ElementCreate that hosts the attribute.

This refactor makes the code clearer in quite a few plases.

Additionally, we now perform a lot of the i18n processing earlier. For example, re-targeting and re-ordering of i18n expressions happens *before* apply instructions are generated. As a result, the re-ordering logic is a lot simpler.

These changes also have consequences on i18n const collection, along with a couple other minor changes.

PR Close #53376
2023-12-06 09:43:36 -08:00
Kristiyan Kostadinov 66ecf4c274 fix(compiler-cli): add compiler option to disable control flow content projection diagnostic (#53387)
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 #53387
2023-12-06 09:43:10 -08:00
Kristiyan Kostadinov 74e6ce5d23 fix(compiler-cli): add diagnostic for control flow that prevents content projection (#53387)
This is a follow-up to the fix from #52414. It adds a diagnostic that will tell users when a control flow is preventing its direct descendants from being projected into a specific component slot.

PR Close #53387
2023-12-06 09:43:10 -08:00
Kristiyan Kostadinov cfa80dc107 test(core): add tests for control flow content projection with ng-container (#53387)
The control flow projection diagnostic will mention `ng-container` as a workaround for projection multiple nodes. These changes add a couple of tests to ensure that the approach works.

PR Close #53387
2023-12-06 09:43:10 -08:00
Kristiyan Kostadinov ec9cc38015 refactor(compiler-cli): expose ng-content selectors and preserveWhitespaces during template type checking (#53387)
These changes expose the `ngContentSelectors` and `preserveWhitespaces` metadata to the TCB so they can be used in the next commit to implement a new diagnostic.

PR Close #53387
2023-12-06 09:43:10 -08:00
Kristiyan Kostadinov cbbd9f3f19 refactor(compiler): expose utility for creating CSS selectors from AST nodes (#53387)
When doing directive matching in the compiler, we need to be able to create a selector from an AST node. We already have the utility, but these changes simplify the public API and expose it so it can be used in `compiler-cli`.

PR Close #53387
2023-12-06 09:43:10 -08:00
Jessica Janiuk 836aeba01d fix(migrations): Change CF Migration ng-template placeholder generation and handling (#53394)
Using more unique characters makes it easier to parse placeholders that may contain JS logic, making it more flexible.

fixes: #53386
fixes: #53385
fixes: #53384

PR Close #53394
2023-12-06 09:42:43 -08:00
Alex Rickabaugh d4fdba5679 Revert "refactor(core): output an error guide link in prod mode (#53324)" (#53392)
This reverts commit f245aba782.

Reason: breaks g3

PR Close #53392
2023-12-06 07:23:24 -08:00
Matthieu Riegler 7c863d728c 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 2a4e3f5373 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 5104a89b30 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:37 -08:00
Dylan Hunn 708131dc01 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:59 -08:00
Matthieu Riegler 20ea149a85 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 2d2eaec2ae docs: fixed wrong template string placeholder (#53286)
PR Close #53286
2023-12-04 21:50:35 -08:00
Joey Perrott 40e8577faf 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:14 -08:00
Joey Perrott dae3e24d14 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:14 -08:00
Joey Perrott 036a2fdc0c 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:14 -08:00
Joey Perrott 9140b027fa 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:13 -08:00
Joey Perrott 857f29b9e9 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:13 -08:00
Joey Perrott 1e424863eb 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:13 -08:00
Joey Perrott 8fc9ff0e9e 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:13 -08:00
Joey Perrott cb460f81cc 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:13 -08:00
Joey Perrott a18b6b9284 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:13 -08:00
Joey Perrott ef553363da 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:13 -08:00
Joey Perrott 4736efc94f 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:12 -08:00
Joey Perrott 069dcd11c8 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:12 -08:00
Joey Perrott 0d7f679d0f 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:12 -08:00
Joey Perrott 24c4c77870 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:12 -08:00
Joey Perrott cb34d35db7 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:12 -08:00
Joey Perrott 7af3237935 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:12 -08:00
Joey Perrott 6312d63b47 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:11 -08:00
Joey Perrott 7e2fe81b74 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:11 -08:00
Joey Perrott 86f0f4adf8 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:11 -08:00
Joey Perrott 90625890c0 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:11 -08:00
Joey Perrott bc1d323345 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:11 -08:00
Kristiyan Kostadinov 6ec7a42b95 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:18 -08:00