Skip to content

Commit 58e1d9e

Browse files
thePunderWomanalxhub
authored andcommitted
refactor(compiler): Add conditionalCreate instruction (angular#60425)
This adds a new instruction for dealing with creating conditionals. It ensures flags are set on the TNode for later identification during hydration. PR Close angular#60425
1 parent 115c2f8 commit 58e1d9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+527
-90
lines changed

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/content_projection/ng_content_fallback.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ $r3$.ɵɵdefineComponent({
6565
$r3$.ɵɵelementStart(2, "div");
6666
$r3$.ɵɵprojection(3, 1, null, TestComponent_ProjectionFallback_3_Template, 5, 1);
6767
$r3$.ɵɵelementEnd();
68-
$r3$.ɵɵtemplate(5, TestComponent_Conditional_5_Template, 2, 0)(6, TestComponent_ng_content_6_Template, 2, 0, "ng-content", 0);
68+
$r3$.ɵɵconditionalCreate(5, TestComponent_Conditional_5_Template, 2, 0);
69+
$r3$.ɵɵtemplate(6, TestComponent_ng_content_6_Template, 2, 0, "ng-content", 0);
6970
}
7071
if (rf & 2) {
7172
$r3$.ɵɵadvance(5);

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/basic_if_else_if_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function MyApp_Template(rf, ctx) {
2626
if (rf & 1) {
2727
$r3$.ɵɵelementStart(0, "div");
2828
$r3$.ɵɵtext(1);
29-
$r3$.ɵɵtemplate(2, MyApp_Conditional_2_Template, 1, 0)(3, MyApp_Conditional_3_Template, 1, 0)(4, MyApp_Conditional_4_Template, 1, 0)(5, MyApp_Conditional_5_Template, 1, 0);
29+
$r3$.ɵɵconditionalCreate(2, MyApp_Conditional_2_Template, 1, 0)(3, MyApp_Conditional_3_Template, 1, 0)(4, MyApp_Conditional_4_Template, 1, 0)(5, MyApp_Conditional_5_Template, 1, 0);
3030
$r3$.ɵɵelementEnd();
3131
}
3232
if (rf & 2) {

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/basic_if_else_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function MyApp_Template(rf, ctx) {
1414
if (rf & 1) {
1515
$r3$.ɵɵelementStart(0, "div");
1616
$r3$.ɵɵtext(1);
17-
$r3$.ɵɵtemplate(2, MyApp_Conditional_2_Template, 1, 0)(3, MyApp_Conditional_3_Template, 1, 0);
17+
$r3$.ɵɵconditionalCreate(2, MyApp_Conditional_2_Template, 1, 0)(3, MyApp_Conditional_3_Template, 1, 0);
1818
$r3$.ɵɵelementEnd();
1919
}
2020
if (rf & 2) {

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/basic_if_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function MyApp_Template(rf, ctx) {
88
if (rf & 1) {
99
$r3$.ɵɵelementStart(0, "div");
1010
$r3$.ɵɵtext(1);
11-
$r3$.ɵɵtemplate(2, MyApp_Conditional_2_Template, 1, 0);
11+
$r3$.ɵɵconditionalCreate(2, MyApp_Conditional_2_Template, 1, 0);
1212
$r3$.ɵɵelementEnd();
1313
}
1414
if (rf & 2) {

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/basic_switch_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function MyApp_Template(rf, ctx) {
2626
if (rf & 1) {
2727
$r3$.ɵɵelementStart(0, "div");
2828
$r3$.ɵɵtext(1);
29-
$r3$.ɵɵtemplate(2, MyApp_Case_2_Template, 1, 0)(3, MyApp_Case_3_Template, 1, 0)(4, MyApp_Case_4_Template, 1, 0)(5, MyApp_Case_5_Template, 1, 0);
29+
$r3$.ɵɵconditionalCreate(2, MyApp_Case_2_Template, 1, 0)(3, MyApp_Case_3_Template, 1, 0)(4, MyApp_Case_4_Template, 1, 0)(5, MyApp_Case_5_Template, 1, 0);
3030
$r3$.ɵɵelementEnd();
3131
}
3232
if (rf & 2) {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 3, 2)(1, MyApp_Conditional_1_Template, 3, 2)(2, MyApp_Conditional_2_Template, 3, 2);
1+
$r3$.ɵɵconditionalCreate(0, MyApp_Conditional_0_Template, 3, 2)(1, MyApp_Conditional_1_Template, 3, 2)(2, MyApp_Conditional_2_Template, 3, 2);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
consts: [["foo", "1", "bar", "2", 3, "binding"], ["foo", "4", "bar", "5", 3, "binding"], ["foo", "7", "bar", "8", 3, "binding"]],
22
3-
$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);
3+
$r3$.ɵɵconditionalCreate(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);

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/if_nested_alias_listeners_template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function MyApp_Conditional_0_Conditional_1_Conditional_1_Template(rf, ctx) {
2424
return $r3$.ɵɵresetView($ctx_r10$.log($ctx_r10$.value(), $root_r1$, $inner_r3$));
2525
});
2626
$r3$.ɵɵelementEnd();
27-
$r3$.ɵɵtemplate(1, MyApp_Conditional_0_Conditional_1_Conditional_1_Template, 1, 0, "button");
27+
$r3$.ɵɵconditionalCreate(1, MyApp_Conditional_0_Conditional_1_Conditional_1_Template, 1, 0, "button");
2828
}
2929
if (rf & 2) {
3030
let $MyApp_Conditional_0_Conditional_1_contFlowTmp$;
@@ -44,7 +44,7 @@ function MyApp_Conditional_0_Conditional_1_Conditional_1_Template(rf, ctx) {
4444
return $r3$.ɵɵresetView($ctx_r13$.log($ctx_r13$.value(), $root_r1$));
4545
});
4646
$r3$.ɵɵelementEnd();
47-
$r3$.ɵɵtemplate(1, MyApp_Conditional_0_Conditional_1_Template, 2, 1);
47+
$r3$.ɵɵconditionalCreate(1, MyApp_Conditional_0_Conditional_1_Template, 2, 1);
4848
}
4949
if (rf & 2) {
5050
let $MyApp_Conditional_0_contFlowTmp$;
@@ -56,7 +56,7 @@ function MyApp_Conditional_0_Conditional_1_Conditional_1_Template(rf, ctx) {
5656
5757
function MyApp_Template(rf, ctx) {
5858
if (rf & 1) {
59-
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 2, 1);
59+
$r3$.ɵɵconditionalCreate(0, MyApp_Conditional_0_Template, 2, 1);
6060
}
6161
if (rf & 2) {
6262
let $MyApp_contFlowTmp$;

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/if_nested_alias_template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function MyApp_Conditional_0_Conditional_1_Conditional_1_Template(rf, ctx) {
1313
function MyApp_Conditional_0_Conditional_1_Template(rf, ctx) {
1414
if (rf & 1) {
1515
$r3$.ɵɵtext(0);
16-
$r3$.ɵɵtemplate(1, MyApp_Conditional_0_Conditional_1_Conditional_1_Template, 1, 4);
16+
$r3$.ɵɵconditionalCreate(1, MyApp_Conditional_0_Conditional_1_Conditional_1_Template, 1, 4);
1717
}
1818
if (rf & 2) {
1919
// NOTE: TODO: These ellipses were added because of a different variable order between
@@ -32,7 +32,7 @@ function MyApp_Conditional_0_Conditional_1_Template(rf, ctx) {
3232
function MyApp_Conditional_0_Template(rf, ctx) {
3333
if (rf & 1) {
3434
$r3$.ɵɵtext(0);
35-
$r3$.ɵɵtemplate(1, MyApp_Conditional_0_Conditional_1_Template, 2, 4);
35+
$r3$.ɵɵconditionalCreate(1, MyApp_Conditional_0_Conditional_1_Template, 2, 4);
3636
}
3737
if (rf & 2) {
3838
@@ -46,7 +46,7 @@ function MyApp_Conditional_0_Template(rf, ctx) {
4646
4747
function MyApp_Template(rf, ctx) {
4848
if (rf & 1) {
49-
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 2, 3);
49+
$r3$.ɵɵconditionalCreate(0, MyApp_Conditional_0_Template, 2, 3);
5050
}
5151
if (rf & 2) {
5252
let $MyApp_contFlowTmp$;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
consts: [["foo", "1", "bar", "2", 3, "binding"], ["foo", "4", "bar", "5", 3, "binding"], ["foo", "7", "bar", "8", 3, "binding"]],
22
3-
$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);
3+
$r3$.ɵɵconditionalCreate(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);

0 commit comments

Comments
 (0)