Skip to content

Commit 289ae50

Browse files
crisbetothePunderWoman
authored andcommitted
refactor(core): replace propertyInterpolateX with property (angular#61639)
Replaces the `propertyInterpolateX` instructions with calls to `property` and the `interpolate` helper. This allows us to drop the dedicated interpolation instructions and simplify the runtime for future work. PR Close angular#61639
1 parent b0425ea commit 289ae50

25 files changed

+68
-961
lines changed

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/order_bindings.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function MyCmp_Template(rf, ctx) {
2727
$r3$.ɵɵstyleProp("style1", ctx.foo);
2828
$r3$.ɵɵclassProp("class1", ctx.foo);
2929
$r3$.ɵɵattribute("attrInterp1", $r3$.ɵɵinterpolate1("interp ", ctx.foo));
30-
$r3$.ɵɵpropertyInterpolate1("propInterp1", "interp ", ctx.foo);
31-
$r3$.ɵɵproperty("prop1", ctx.foo);
30+
$r3$.ɵɵproperty("propInterp1", $r3$.ɵɵinterpolate1("interp ", ctx.foo))("prop1", ctx.foo);
3231
$r3$.ɵɵattribute("attr1", ctx.foo);
3332
}
3433
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
template: function MyComponent_Template(rf, ctx) {
22
33
if (rf & 2) {
4-
$r3$.ɵɵpropertyInterpolate("tabindex", 0 + 3);
5-
$r3$.ɵɵpropertyInterpolate2("aria-label", "hello-", 1 + 3, "-", 2 + 3);
6-
$r3$.ɵɵproperty("title", 1)("id", 2);
4+
$r3$.ɵɵproperty("tabindex", $r3$.ɵɵinterpolate(0 + 3))("aria-label", $r3$.ɵɵinterpolate2("hello-", 1 + 3, "-", 2 + 3))("title", 1)("id", 2);
75
}
86
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
template: function MyComponent_Template(rf, ctx) {
22
33
if (rf & 2) {
4-
$r3$.ɵɵpropertyInterpolate("aria-label", 1 + 3);
5-
$r3$.ɵɵproperty("title", 1)("tabindex", 3);
4+
$r3$.ɵɵproperty("aria-label", $r3$.ɵɵinterpolate(1 + 3))("title", 1)("tabindex", 3);
65
$r3$.ɵɵattribute("id", 2);
76
}
87
}
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
if (rf & 2) {
2-
i0.ɵɵpropertyInterpolateV("title", ["a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i", ctx.nine, "j"]);
3-
i0.ɵɵadvance();
4-
i0.ɵɵpropertyInterpolate8("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i");
5-
i0.ɵɵadvance();
6-
i0.ɵɵpropertyInterpolate7("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h");
7-
i0.ɵɵadvance();
8-
i0.ɵɵpropertyInterpolate6("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g");
9-
i0.ɵɵadvance();
10-
i0.ɵɵpropertyInterpolate5("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f");
11-
i0.ɵɵadvance();
12-
i0.ɵɵpropertyInterpolate4("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e");
13-
i0.ɵɵadvance();
14-
i0.ɵɵpropertyInterpolate3("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d");
15-
i0.ɵɵadvance();
16-
i0.ɵɵpropertyInterpolate2("title", "a", ctx.one, "b", ctx.two, "c");
17-
i0.ɵɵadvance();
18-
i0.ɵɵpropertyInterpolate1("title", "a", ctx.one, "b");
19-
i0.ɵɵadvance();
20-
i0.ɵɵpropertyInterpolate("title", ctx.one);
2+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolateV(["a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i", ctx.nine, "j"]));
3+
$r3$.ɵɵadvance();
4+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate8("a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i"));
5+
$r3$.ɵɵadvance();
6+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate7("a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h"));
7+
$r3$.ɵɵadvance();
8+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate6("a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g"));
9+
$r3$.ɵɵadvance();
10+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate5("a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f"));
11+
$r3$.ɵɵadvance();
12+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate4("a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e"));
13+
$r3$.ɵɵadvance();
14+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate3("a", ctx.one, "b", ctx.two, "c", ctx.three, "d"));
15+
$r3$.ɵɵadvance();
16+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate2("a", ctx.one, "b", ctx.two, "c"));
17+
$r3$.ɵɵadvance();
18+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate1("a", ctx.one, "b"));
19+
$r3$.ɵɵadvance();
20+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate(ctx.one));
2121
}
2222

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/property_bindings/interpolation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ template:function MyComponent_Template(rf, $ctx$){
66
$i0$.ɵɵelement(0, "a", 0);
77
}
88
if (rf & 2) {
9-
$i0$.ɵɵpropertyInterpolate1("title", "Hello ", $ctx$.name);
9+
$i0$.ɵɵproperty("title", $r3$.ɵɵinterpolate1("Hello ", $ctx$.name));
1010
}
1111
}

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_bindings/property_bindings/sanitization.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ template: function MyComponent_Template(rf, ctx) {
1313
$r3$.ɵɵadvance();
1414
$r3$.ɵɵproperty("sandbox", ctx.evil, $r3$.ɵɵvalidateIframeAttribute);
1515
$r3$.ɵɵadvance();
16-
$r3$.ɵɵpropertyInterpolate2("href", "", ctx.evil, "", ctx.evil, "", $r3$.ɵɵsanitizeUrl);
16+
$r3$.ɵɵproperty("href", $r3$.ɵɵinterpolate2("", ctx.evil, "", ctx.evil), $r3$.ɵɵsanitizeUrl);
1717
$r3$.ɵɵadvance();
1818
$r3$.ɵɵattribute("style", $r3$.ɵɵinterpolate2("", ctx.evil, "", ctx.evil), $r3$.ɵɵsanitizeStyle);
1919
}

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/attribute_interpolation.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ consts: () => {
99
} else {
1010
$i18n_1$ = $localize`{VAR_SELECT, select, other {{START_TAG_SPAN}foo{CLOSE_TAG_SPAN}}}`;
1111
}
12-
$i18n_1$ = i0.ɵɵi18nPostprocess($i18n_1$, {
12+
$i18n_1$ = $r3$.ɵɵi18nPostprocess($i18n_1$, {
1313
"CLOSE_TAG_SPAN": "</span>",
1414
"START_TAG_SPAN": "<span title=\"\uFFFD1\uFFFD-\uFFFD2\uFFFD\">",
1515
"VAR_SELECT": "\uFFFD0\uFFFD"
@@ -24,7 +24,7 @@ consts: () => {
2424
} else {
2525
$i18n_3$ = $localize`{VAR_SELECT, select, other {{INTERPOLATION}-{INTERPOLATION}}}`;
2626
}
27-
$i18n_3$ = i0.ɵɵi18nPostprocess($i18n_3$, {
27+
$i18n_3$ = $r3$.ɵɵi18nPostprocess($i18n_3$, {
2828
"INTERPOLATION": "\uFFFD4\uFFFD",
2929
"VAR_SELECT": "\uFFFD3\uFFFD"
3030
});
@@ -54,22 +54,22 @@ consts: () => {
5454
} else {
5555
$i18n_0$ = $localize`${"\uFFFD#2\uFFFD"}:START_TAG_SPAN:${"[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]"}:CLOSE_TAG_SPAN:${"[\uFFFD#3\uFFFD|\uFFFD#4\uFFFD]"}:START_TAG_SPAN_1:${$i18n_1$}:ICU@@6051755734147382484:${"[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]"}:CLOSE_TAG_SPAN:${"[\uFFFD#3\uFFFD|\uFFFD#4\uFFFD]"}:START_TAG_SPAN_1:${$i18n_3$}:ICU_1@@7593934392904803263:${"[\uFFFD/#2\uFFFD|\uFFFD/#3\uFFFD|\uFFFD/#4\uFFFD]"}:CLOSE_TAG_SPAN:`;
5656
}
57-
$i18n_0$ = i0.ɵɵi18nPostprocess($i18n_0$);
57+
$i18n_0$ = $r3$.ɵɵi18nPostprocess($i18n_0$);
5858
return [$i18n_0$, [3, "title"]];
5959
},
6060
template: function MyComponent_Template(rf, ctx) {
6161
if (rf & 1) {
62-
i0.ɵɵelementStart(0, "div");
63-
i0.ɵɵi18nStart(1, 0);
64-
i0.ɵɵelement(2, "span", 1)(3, "span")(4, "span");
65-
i0.ɵɵi18nEnd();
66-
i0.ɵɵelementEnd();
62+
$r3$.ɵɵelementStart(0, "div");
63+
$r3$.ɵɵi18nStart(1, 0);
64+
$r3$.ɵɵelement(2, "span", 1)(3, "span")(4, "span");
65+
$r3$.ɵɵi18nEnd();
66+
$r3$.ɵɵelementEnd();
6767
}
6868
if (rf & 2) {
69-
i0.ɵɵadvance(2);
70-
i0.ɵɵpropertyInterpolate2("title", "", ctx.foo, "-", ctx.foo);
71-
i0.ɵɵadvance(2);
72-
i0.ɵɵi18nExp(ctx.foo)(ctx.foo)(ctx.foo)(ctx.foo)(ctx.foo);
73-
i0.ɵɵi18nApply(1);
69+
$r3$.ɵɵadvance(2);
70+
$r3$.ɵɵproperty("title", $r3$.ɵɵinterpolate2("", ctx.foo, "-", ctx.foo));
71+
$r3$.ɵɵadvance(2);
72+
$r3$.ɵɵi18nExp(ctx.foo)(ctx.foo)(ctx.foo)(ctx.foo)(ctx.foo);
73+
$r3$.ɵɵi18nApply(1);
7474
}
7575
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
consts: [[__AttributeMarker.Bindings__, "dir"]],
22
template: function TestComp_Template(rf, ctx) {
33
if (rf & 1) {
4-
$i0$.ɵɵtemplate(0, $TestComp_ng_template_0_Template$, 0, 0, "ng-template", 0);
4+
$r3$.ɵɵtemplate(0, $TestComp_ng_template_0_Template$, 0, 0, "ng-template", 0);
55
}
66
if (rf & 2) {
7-
$i0$.ɵɵpropertyInterpolate("dir", ctx.message);
7+
$r3$.ɵɵproperty("dir", $r3$.ɵɵinterpolate(ctx.message));
88
}
99
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function $TestComp_0_Template$(rf, ctx) {
22
if (rf & 1) {
3-
$i0$.ɵɵtemplate(0, $TestComp_0_ng_template_0_Template$, 0, 0, "ng-template", 1);
3+
$r3$.ɵɵtemplate(0, $TestComp_0_ng_template_0_Template$, 0, 0, "ng-template", 1);
44
}
55
if (rf & 2) {
66
const $ctx_r0$ = i0.ɵɵnextContext();
7-
$i0$.ɵɵpropertyInterpolate("dir", $ctx_r0$.message);
7+
$r3$.ɵɵproperty("dir", $r3$.ɵɵinterpolate($ctx_r0$.message));
88
}
99
}

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_template/ng_template_interpolated_prop_with_structural_directive_outer_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
consts: [[4, "ngIf"], [3, "dir"]],
22
template: function TestComp_Template(rf, ctx) {
33
if (rf & 1) {
4-
$i0$.ɵɵtemplate(0, $TestComp_0_Template$, 1, 1, null, 0);
4+
$i0$.ɵɵtemplate(0, $TestComp_0_Template$, 1, 2, null, 0);
55
}
66
if (rf & 2) {
77
$i0$.ɵɵproperty("ngIf", true);

0 commit comments

Comments
 (0)