-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): capture all control flow branches for content projecti…
…on in if blocks (#54921) Previously only the first branch of an `if` block was captured for content projection. This was done because of some planned refactors in the future. Since we've decided not to apply those refactors to conditionals, these changes update the compiler to capture each branch individually for content projection purposes. PR Close #54921
- Loading branch information
Showing
12 changed files
with
240 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
...er-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_template_root_node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...st/compliance/test_cases/r3_view_compiler_control_flow/for_template_root_node_template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
consts: [["foo", "1", "bar", "2"], ["empty-foo", "1", "empty-bar", "2"]] | ||
consts: [["foo", "1", "bar", "2", 3, "binding"], ["empty-foo", "1", "empty-bar", "2", 3, "binding"]] | ||
… | ||
$r3$.ɵɵrepeaterCreate(0, MyApp_For_1_Template, 1, 0, null, 0, i0.ɵɵrepeaterTrackByIdentity, false, MyApp_ForEmpty_2_Template, 1, 0, null, 1); | ||
$r3$.ɵɵrepeaterCreate(0, MyApp_For_1_Template, 1, 1, null, 0, i0.ɵɵrepeaterTrackByIdentity, false, MyApp_ForEmpty_2_Template, 1, 1, null, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...test/compliance/test_cases/r3_view_compiler_control_flow/if_element_root_node_template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
consts: [["foo", "1", "bar", "2", 3, "binding"]] | ||
consts: [["foo", "1", "bar", "2", 3, "binding"], ["foo", "4", "bar", "5", 3, "binding"], ["foo", "7", "bar", "8", 3, "binding"]], | ||
… | ||
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 2, 2, "div", 0); | ||
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 2, 2, "div", 0)(1, MyApp_Conditional_1_Template, 2, 2, "div", 1)(2, MyApp_Conditional_2_Template, 2, 2, "div", 2); |
20 changes: 16 additions & 4 deletions
20
...ler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/if_template_root_node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
import {Component} from '@angular/core'; | ||
import {Component, Directive, Input} from '@angular/core'; | ||
|
||
@Directive({standalone: true, selector: '[binding]'}) | ||
export class Binding { | ||
@Input() binding = 0; | ||
} | ||
|
||
|
||
@Component({ | ||
template: ` | ||
@if (expr) { | ||
<ng-template foo="1" bar="2">{{expr}}</ng-template> | ||
@if (expr === 0) { | ||
<ng-template foo="1" bar="2" [binding]="3">{{expr}}</ng-template> | ||
} @else if (expr === 1) { | ||
<ng-template foo="4" bar="5" [binding]="6">{{expr}}</ng-template> | ||
} @else { | ||
<ng-template foo="7" bar="8" [binding]="9">{{expr}}</ng-template> | ||
} | ||
`, | ||
standalone: true, | ||
imports: [Binding], | ||
}) | ||
export class MyApp { | ||
expr = true; | ||
expr = 0; | ||
} |
4 changes: 2 additions & 2 deletions
4
...est/compliance/test_cases/r3_view_compiler_control_flow/if_template_root_node_template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
consts: [["foo", "1", "bar", "2"]] | ||
consts: [["foo", "1", "bar", "2", 3, "binding"], ["foo", "4", "bar", "5", 3, "binding"], ["foo", "7", "bar", "8", 3, "binding"]], | ||
… | ||
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 1, 0, null, 0); | ||
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 1, 1, null, 0)(1, MyApp_Conditional_1_Template, 1, 1, null, 1)(2, MyApp_Conditional_2_Template, 1, 1, null, 2); |
Oops, something went wrong.