mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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 |
||
|---|---|---|
| .. | ||
| r3_compiler_compliance | ||
| r3_view_compiler | ||
| r3_view_compiler_bindings | ||
| r3_view_compiler_control_flow | ||
| r3_view_compiler_deferred | ||
| r3_view_compiler_di/di | ||
| r3_view_compiler_directives | ||
| r3_view_compiler_i18n | ||
| r3_view_compiler_input_outputs | ||
| r3_view_compiler_listener | ||
| r3_view_compiler_providers | ||
| r3_view_compiler_styling | ||
| r3_view_compiler_template | ||
| source_mapping | ||
| BUILD.bazel | ||
| list_golden_update_rules.ts | ||
| test_case_schema.json | ||