angular/packages/compiler-cli/test/compliance/test_cases
Kristiyan Kostadinov d9d566d315 fix(compiler): nested for loops incorrectly calculating computed variables (#52931)
The `$first`, `$last`, `$even` and `$odd` variables in `@for` loops aren't defined on the template context of the loop, but are computed based on `$index` and `$count` (e.g. `$first` is defined as `$index === 0`). We do this calculation by looking up `$index` and `$count` when one of the variables is used.

The problem is that all `@for` loop variables are available implicitly which means that when a nested loop tries to rewrite a reference to an outer loop computed variable, it finds its own `$index` and `$count` first and it doesn't look up the ones on the parent at all. This means that the calculated values will be incorrect at runtime.

These changes work around the issue by defining nested-level-specific variable names that can be used for lookups (e.g. `$index` at level `2` will also be available as `ɵ$index_2`). This isn't the most elegant solution, however the `TemplatDefitinionBuilder` wasn't set up to handle shadowed variables like this and it doesn't make sense to refactor it given the upcoming template pipeline.

Fixes #52917.

PR Close #52931
2023-11-16 09:29:46 -08:00
..
r3_compiler_compliance refactor(compiler): Add template pipeline golden for differing consts (#52479) 2023-11-06 11:42:58 -08:00
r3_view_compiler refactor: fix a number of typos throughout the codebase (#52249) 2023-10-25 16:51:24 -07:00
r3_view_compiler_bindings refactor(compiler): Add template pipeline goldens for some tests with const attributes (#52479) 2023-11-06 11:42:58 -08:00
r3_view_compiler_control_flow fix(compiler): nested for loops incorrectly calculating computed variables (#52931) 2023-11-16 09:29:46 -08:00
r3_view_compiler_deferred refactor(compiler): Support extracting deps functions for defer in template pipeline (#52479) 2023-11-06 11:42:59 -08:00
r3_view_compiler_di/di perf(compiler): further reduce bundle size using arrow functions (#52010) 2023-10-04 07:25:54 -07:00
r3_view_compiler_directives perf(compiler): further reduce bundle size using arrow functions (#52010) 2023-10-04 07:25:54 -07:00
r3_view_compiler_i18n refactor(compiler): Handle trailing spaces in ICU placeholders (#52698) 2023-11-10 17:01:07 +00:00
r3_view_compiler_input_outputs fix(compiler-cli): enforce a minimum version to be used when a library uses input transform (#51413) 2023-08-18 07:58:53 -07:00
r3_view_compiler_listener refactor(compiler): Fix two-way bindings in template pipeline (#52479) 2023-11-06 11:42:59 -08:00
r3_view_compiler_providers fix(compiler-cli): libraries compiled with v16.1+ breaking with Angular framework v16.0.x (#50714) 2023-06-14 16:27:59 +02:00
r3_view_compiler_styling refactor(compiler): Order elements before other phases (#52289) 2023-10-24 11:07:49 -07:00
r3_view_compiler_template refactor(compiler): Emit a template ref extractor on ng-templates with local refs (#52479) 2023-11-06 11:42:59 -08:00
source_mapping refactor(compiler): Fix two-way binding source maps (#52479) 2023-11-06 11:42:59 -08:00
BUILD.bazel test: refactor compiler-cli compliance test to work on windows (#45431) 2022-03-25 12:18:34 -07:00
list_golden_update_rules.ts refactor(compiler-cli): use semver range checking for partial versions (#39847) 2020-12-04 10:26:17 -08:00
test_case_schema.json test(compiler): allow alternate expected file for template pipeline (#51100) 2023-08-01 13:45:34 -07:00