angular/packages/compiler-cli/test/compliance/test_cases
Kristiyan Kostadinov eb15358479 fix(compiler): project control flow root elements into correct slot (#52414)
With the directive-based control flow users were able to conditionally project content using the `*` syntax. E.g. `<div *ngIf="expr" projectMe></div>` will be projected into `<ng-content select="[projectMe]"/>`, because the attributes and tag name from the `div` are copied to the template via the template creation instruction. With `@if` and `@for` that is not the case, because the conditional is placed *around* elements, rather than *on* them. The result is that content projection won't work in the same way if a user converts from `*ngIf` to `@if`.

These changes aim to cover the most common case by doing the same copying when a control flow node has *one and only one* root element or template node.

This approach comes with some caveats:
1. As soon as any other node is added to the root, the copying behavior won't work anymore. A diagnostic will be added to flag cases like this and to explain how to work around it.
2. If `preserveWhitespaces` is enabled, it's very likely that indentation will break this workaround, because it'll include an additional text node as the first child. We can work around it here, but in a discussion it was decided not to, because the user explicitly opted into preserving the whitespace and we would have to drop it from the generated code. The diagnostic mentioned point #1 will flag such cases to users.

Fixes #52277.

PR Close #52414
2023-10-31 14:52:30 -07:00
..
r3_compiler_compliance refactor(compiler): Update pipe test golden for alternative create order (#52289) 2023-10-24 11:07:49 -07: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): Improve the ordering of update ops (#52289) 2023-10-24 11:07:49 -07:00
r3_view_compiler_control_flow fix(compiler): project control flow root elements into correct slot (#52414) 2023-10-31 14:52:30 -07:00
r3_view_compiler_deferred refactor(compiler): Implement the remaining defer on triggers (#52387) 2023-10-31 12:45:18 -07: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 test(compiler): Enable passing i18n tests (#52390) 2023-10-27 16:16:04 -07: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): Use already available context in closures, instead of saving it (#52289) 2023-10-24 11:07:48 -07: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): Fix a special case involving var counting for singleton propertyInterpolate (#52289) 2023-10-24 11:07:49 -07:00
source_mapping refactor(compiler): Support content projection source maps (#52289) 2023-10-24 11:07:50 -07: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