Skip to content

Commit 10217bb

Browse files
committed
feat(ivy): generate ɵɵproperty instructions (angular#29946)
PR Close angular#29946
1 parent a181e8e commit 10217bb

22 files changed

+327
-191
lines changed

packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts

+30-23
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ describe('compiler compliance', () => {
317317
}
318318
if (rf & 2) {
319319
$r3$.ɵɵselect(0);
320-
$r3$.ɵɵelementProperty(0, "id", $r3$.ɵɵbind(ctx.id));
320+
$r3$.ɵɵproperty("id", ctx.id);
321321
}
322322
}
323323
`;
@@ -354,6 +354,14 @@ describe('compiler compliance', () => {
354354
}
355355
};
356356

357+
///////////////
358+
// TODO(FW-1273): The code generated below is adding extra parens, and we need to stop
359+
// generating those.
360+
//
361+
// For example:
362+
// `$r3$.ɵɵproperty("ternary", (ctx.cond ? $r3$.ɵɵpureFunction1(8, $c0$, ctx.a): $c1$));`
363+
///////////////
364+
357365
const $e0_attrs$ = [];
358366
const factory =
359367
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
@@ -365,10 +373,10 @@ describe('compiler compliance', () => {
365373
}
366374
if (rf & 2) {
367375
$r3$.ɵɵselect(0);
368-
$r3$.ɵɵelementProperty(0, "ternary", $r3$.ɵɵbind((ctx.cond ? $r3$.ɵɵpureFunction1(8, $c0$, ctx.a): $c1$)));
369-
$r3$.ɵɵelementProperty(0, "pipe", $r3$.ɵɵbind($r3$.ɵɵpipeBind3(1, 4, ctx.value, 1, 2)));
370-
$r3$.ɵɵelementProperty(0, "and", $r3$.ɵɵbind((ctx.cond && $r3$.ɵɵpureFunction1(10, $c0$, ctx.b))));
371-
$r3$.ɵɵelementProperty(0, "or", $r3$.ɵɵbind((ctx.cond || $r3$.ɵɵpureFunction1(12, $c0$, ctx.c))));
376+
$r3$.ɵɵproperty("ternary", (ctx.cond ? $r3$.ɵɵpureFunction1(8, $c0$, ctx.a): $c1$));
377+
$r3$.ɵɵproperty("pipe", $r3$.ɵɵpipeBind3(1, 4, ctx.value, 1, 2));
378+
$r3$.ɵɵproperty("and", (ctx.cond && $r3$.ɵɵpureFunction1(10, $c0$, ctx.b)));
379+
$r3$.ɵɵproperty("or", (ctx.cond || $r3$.ɵɵpureFunction1(12, $c0$, ctx.c)));
372380
}
373381
}
374382
`;
@@ -880,7 +888,7 @@ describe('compiler compliance', () => {
880888
}
881889
if (rf & 2) {
882890
$r3$.ɵɵselect(0);
883-
$r3$.ɵɵelementProperty(0, "names", $r3$.ɵɵbind($r3$.ɵɵpureFunction1(1, $e0_ff$, ctx.customName)));
891+
$r3$.ɵɵproperty("names", $r3$.ɵɵpureFunction1(1, $e0_ff$, ctx.customName));
884892
}
885893
},
886894
directives: [MyComp],
@@ -963,9 +971,8 @@ describe('compiler compliance', () => {
963971
}
964972
if (rf & 2) {
965973
$r3$.ɵɵselect(0);
966-
$r3$.ɵɵelementProperty(
967-
0, "names",
968-
$r3$.ɵɵbind($r3$.ɵɵpureFunctionV(1, $e0_ff$, [ctx.n0, ctx.n1, ctx.n2, ctx.n3, ctx.n4, ctx.n5, ctx.n6, ctx.n7, ctx.n8])));
974+
$r3$.ɵɵproperty("names",
975+
$r3$.ɵɵpureFunctionV(1, $e0_ff$, [ctx.n0, ctx.n1, ctx.n2, ctx.n3, ctx.n4, ctx.n5, ctx.n6, ctx.n7, ctx.n8]));
969976
}
970977
},
971978
directives: [MyComp],
@@ -1028,7 +1035,7 @@ describe('compiler compliance', () => {
10281035
}
10291036
if (rf & 2) {
10301037
$r3$.ɵɵselect(0);
1031-
$r3$.ɵɵelementProperty(0, "config", $r3$.ɵɵbind($r3$.ɵɵpureFunction1(1, $e0_ff$, ctx.name)));
1038+
$r3$.ɵɵproperty("config", $r3$.ɵɵpureFunction1(1, $e0_ff$, ctx.name));
10321039
}
10331040
},
10341041
directives: [ObjectComp],
@@ -1097,9 +1104,9 @@ describe('compiler compliance', () => {
10971104
}
10981105
if (rf & 2) {
10991106
$r3$.ɵɵselect(0);
1100-
$r3$.ɵɵelementProperty(
1101-
0, "config",
1102-
$r3$.ɵɵbind($r3$.ɵɵpureFunction2(5, $e0_ff_2$, ctx.name, $r3$.ɵɵpureFunction1(3, $e0_ff_1$, $r3$.ɵɵpureFunction1(1, $e0_ff$, ctx.duration)))));
1107+
$r3$.ɵɵproperty(
1108+
"config",
1109+
$r3$.ɵɵpureFunction2(5, $e0_ff_2$, ctx.name, $r3$.ɵɵpureFunction1(3, $e0_ff_1$, $r3$.ɵɵpureFunction1(1, $e0_ff$, ctx.duration))));
11031110
}
11041111
},
11051112
directives: [NestedComp],
@@ -1261,9 +1268,9 @@ describe('compiler compliance', () => {
12611268
}
12621269
if (rf & 2) {
12631270
$r3$.ɵɵselect(0);
1264-
$r3$.ɵɵelementProperty(0, "ngIf", $r3$.ɵɵbind(ctx.visible));
1271+
$r3$.ɵɵproperty("ngIf", ctx.visible);
12651272
$r3$.ɵɵselect(1);
1266-
$r3$.ɵɵelementProperty(1, "ngIf", $r3$.ɵɵbind(ctx.visible));
1273+
$r3$.ɵɵproperty("ngIf", ctx.visible);
12671274
}
12681275
}
12691276
`;
@@ -2350,7 +2357,7 @@ describe('compiler compliance', () => {
23502357
if (rf & 2) {
23512358
const $app$ = $i0$.ɵɵnextContext();
23522359
$r3$.ɵɵselect(3);
2353-
$i0$.ɵɵelementProperty(3, "ngIf", $i0$.ɵɵbind($app$.showing));
2360+
$i0$.ɵɵproperty("ngIf", $app$.showing);
23542361
}
23552362
}
23562363
@@ -2361,7 +2368,7 @@ describe('compiler compliance', () => {
23612368
}
23622369
if (rf & 2) {
23632370
$i0$.ɵɵselect(0);
2364-
$i0$.ɵɵelementProperty(0, "ngForOf", $i0$.ɵɵbind(ctx.items));
2371+
$i0$.ɵɵproperty("ngForOf", ctx.items);
23652372
}
23662373
}`;
23672374

@@ -2442,9 +2449,9 @@ describe('compiler compliance', () => {
24422449
}
24432450
if (rf & 2) {
24442451
$r3$.ɵɵselect(0);
2445-
$r3$.ɵɵelementProperty(0, "name", $r3$.ɵɵbind(ctx.name1));
2452+
$r3$.ɵɵproperty("name", ctx.name1);
24462453
$r3$.ɵɵselect(1);
2447-
$r3$.ɵɵelementProperty(1, "name", $r3$.ɵɵbind(ctx.name2));
2454+
$r3$.ɵɵproperty("name", ctx.name2);
24482455
}
24492456
},
24502457
directives: [LifecycleComp],
@@ -2576,7 +2583,7 @@ describe('compiler compliance', () => {
25762583
}
25772584
if (rf & 2) {
25782585
$r3$.ɵɵselect(1);
2579-
$r3$.ɵɵelementProperty(1,"forOf",$r3$.ɵɵbind(ctx.items));
2586+
$r3$.ɵɵproperty("forOf", ctx.items);
25802587
}
25812588
},
25822589
directives: function() { return [ForOfDirective]; },
@@ -2658,7 +2665,7 @@ describe('compiler compliance', () => {
26582665
}
26592666
if (rf & 2) {
26602667
$r3$.ɵɵselect(1);
2661-
$r3$.ɵɵelementProperty(1, "forOf", $r3$.ɵɵbind(ctx.items));
2668+
$r3$.ɵɵproperty("forOf", ctx.items);
26622669
}
26632670
},
26642671
directives: function() { return [ForOfDirective]; },
@@ -2743,7 +2750,7 @@ describe('compiler compliance', () => {
27432750
$r3$.ɵɵselect(2);
27442751
$r3$.ɵɵtextBinding(2, $r3$.ɵɵinterpolation1("", IDENT.name, ""));
27452752
$r3$.ɵɵselect(4);
2746-
$r3$.ɵɵelementProperty(4, "forOf", $r3$.ɵɵbind(IDENT.infos));
2753+
$r3$.ɵɵproperty("forOf", IDENT.infos);
27472754
}
27482755
}
27492756
@@ -2762,7 +2769,7 @@ describe('compiler compliance', () => {
27622769
}
27632770
if (rf & 2) {
27642771
$r3$.ɵɵselect(1);
2765-
$r3$.ɵɵelementProperty(1, "forOf", $r3$.ɵɵbind(ctx.items));
2772+
$r3$.ɵɵproperty("forOf", ctx.items);
27662773
}
27672774
},
27682775
directives: function () { return [ForOfDirective]; },

packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('compiler compliance: bindings', () => {
8282
}
8383
if (rf & 2) {
8484
$i0$.ɵɵselect(0);
85-
$i0$.ɵɵelementProperty(0, "title", $i0$.ɵɵbind($ctx$.title));
85+
$i0$.ɵɵproperty("title", $ctx$.title);
8686
}
8787
}`;
8888
const result = compile(files, angularFiles);
@@ -174,7 +174,7 @@ describe('compiler compliance: bindings', () => {
174174
}
175175
if (rf & 2) {
176176
$i0$.ɵɵselect(0);
177-
$i0$.ɵɵelementProperty(0, "for", $i0$.ɵɵbind(ctx.forValue));
177+
$i0$.ɵɵproperty("for", ctx.forValue);
178178
}
179179
}`;
180180

packages/compiler-cli/test/compliance/r3_view_compiler_directives_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe('compiler compliance: directives', () => {
140140
}
141141
if (rf & 2) {
142142
$r3$.ɵɵselect(0);
143-
$r3$.ɵɵelementProperty(0, "someDirective", $r3$.ɵɵbind(true));
143+
$r3$.ɵɵproperty("someDirective", true);
144144
}
145145
},
146146
@@ -255,7 +255,7 @@ describe('compiler compliance: directives', () => {
255255
}
256256
if (rf & 2) {
257257
$r3$.ɵɵselect(0);
258-
$r3$.ɵɵelementProperty(0, "ngIf", $r3$.ɵɵbind(ctx.showing));
258+
$r3$.ɵɵproperty("ngIf", ctx.showing);
259259
}
260260
},
261261
@@ -303,7 +303,7 @@ describe('compiler compliance: directives', () => {
303303
}
304304
if (rf & 2) {
305305
$r3$.ɵɵselect(0);
306-
$r3$.ɵɵelementProperty(0, "someDirective", $r3$.ɵɵbind(true));
306+
$r3$.ɵɵproperty("someDirective", true);
307307
}
308308
},
309309

packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ describe('i18n support in the view compiler', () => {
580580
}
581581
if (rf & 2) {
582582
$r3$.ɵɵselect(0);
583-
$r3$.ɵɵelementProperty(0, "ngForOf", $r3$.ɵɵbind(ctx.items));
583+
$r3$.ɵɵproperty("ngForOf", ctx.items);
584584
}
585585
}
586586
`;
@@ -767,7 +767,7 @@ describe('i18n support in the view compiler', () => {
767767
}
768768
if (rf & 2) {
769769
$r3$.ɵɵselect(0);
770-
$r3$.ɵɵelementProperty(0, "ngForOf", $r3$.ɵɵbind(ctx.items));
770+
$r3$.ɵɵproperty("ngForOf", ctx.items);
771771
}
772772
}
773773
`;
@@ -1429,7 +1429,7 @@ describe('i18n support in the view compiler', () => {
14291429
}
14301430
if (rf & 2) {
14311431
$r3$.ɵɵselect(2);
1432-
$r3$.ɵɵelementProperty(2, "ngIf", $r3$.ɵɵbind(ctx.visible));
1432+
$r3$.ɵɵproperty("ngIf", ctx.visible);
14331433
}
14341434
}
14351435
`;
@@ -1491,9 +1491,9 @@ describe('i18n support in the view compiler', () => {
14911491
}
14921492
if (rf & 2) {
14931493
$r3$.ɵɵselect(1);
1494-
$r3$.ɵɵelementProperty(1, "ngIf", $r3$.ɵɵbind(ctx.visible));
1494+
$r3$.ɵɵproperty("ngIf", ctx.visible);
14951495
$r3$.ɵɵselect(2);
1496-
$r3$.ɵɵelementProperty(2, "ngIf", $r3$.ɵɵbind(ctx.visible));
1496+
$r3$.ɵɵproperty("ngIf", ctx.visible);
14971497
}
14981498
}
14991499
`;
@@ -1558,7 +1558,7 @@ describe('i18n support in the view compiler', () => {
15581558
if (rf & 2) {
15591559
const $ctx_r0$ = $r3$.ɵɵnextContext();
15601560
$r3$.ɵɵselect(4);
1561-
$r3$.ɵɵelementProperty(4, "ngIf", $r3$.ɵɵbind($ctx_r0$.exists));
1561+
$r3$.ɵɵproperty("ngIf", $ctx_r0$.exists);
15621562
$r3$.ɵɵi18nExp($r3$.ɵɵbind($ctx_r0$.valueA));
15631563
$r3$.ɵɵi18nExp($r3$.ɵɵbind($r3$.ɵɵpipeBind1(3, 3, $ctx_r0$.valueB)));
15641564
$r3$.ɵɵi18nApply(0);
@@ -1628,9 +1628,9 @@ describe('i18n support in the view compiler', () => {
16281628
}
16291629
if (rf & 2) {
16301630
$r3$.ɵɵselect(2);
1631-
$r3$.ɵɵelementProperty(2, "ngIf", $r3$.ɵɵbind(ctx.visible));
1631+
$r3$.ɵɵproperty("ngIf", ctx.visible);
16321632
$r3$.ɵɵselect(3);
1633-
$r3$.ɵɵelementProperty(3, "ngIf", $r3$.ɵɵbind(!ctx.visible));
1633+
$r3$.ɵɵproperty("ngIf", !ctx.visible);
16341634
}
16351635
}
16361636
`;
@@ -1686,7 +1686,7 @@ describe('i18n support in the view compiler', () => {
16861686
}
16871687
if (rf & 2) {
16881688
$r3$.ɵɵselect(0);
1689-
$r3$.ɵɵelementProperty(0, "ngIf", $r3$.ɵɵbind(ctx.visible));
1689+
$r3$.ɵɵproperty("ngIf", ctx.visible);
16901690
}
16911691
}
16921692
`;
@@ -2597,9 +2597,9 @@ describe('i18n support in the view compiler', () => {
25972597
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.gender));
25982598
$r3$.ɵɵi18nApply(1);
25992599
$r3$.ɵɵselect(2);
2600-
$r3$.ɵɵelementProperty(2, "ngIf", $r3$.ɵɵbind(ctx.visible));
2600+
$r3$.ɵɵproperty("ngIf", ctx.visible);
26012601
$r3$.ɵɵselect(3);
2602-
$r3$.ɵɵelementProperty(3, "ngIf", $r3$.ɵɵbind(ctx.available));
2602+
$r3$.ɵɵproperty("ngIf", ctx.available);
26032603
}
26042604
}
26052605
`;
@@ -2935,7 +2935,7 @@ describe('i18n support in the view compiler', () => {
29352935
}
29362936
if (rf & 2) {
29372937
$r3$.ɵɵselect(3);
2938-
$r3$.ɵɵelementProperty(3, "ngIf", $r3$.ɵɵbind(ctx.visible));
2938+
$r3$.ɵɵproperty("ngIf", ctx.visible);
29392939
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.gender));
29402940
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.gender));
29412941
$r3$.ɵɵi18nApply(1);
@@ -3075,7 +3075,7 @@ describe('i18n support in the view compiler', () => {
30753075
}
30763076
if (rf & 2) {
30773077
$r3$.ɵɵselect(2);
3078-
$r3$.ɵɵelementProperty(2, "ngIf", $r3$.ɵɵbind(ctx.ageVisible));
3078+
$r3$.ɵɵproperty("ngIf", ctx.ageVisible);
30793079
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.gender));
30803080
$r3$.ɵɵi18nApply(1);
30813081
}
@@ -3174,7 +3174,7 @@ describe('i18n support in the view compiler', () => {
31743174
}
31753175
if (rf & 2) {
31763176
$r3$.ɵɵselect(2);
3177-
$r3$.ɵɵelementProperty(2, "ngIf", $r3$.ɵɵbind(ctx.ageVisible));
3177+
$r3$.ɵɵproperty("ngIf", ctx.ageVisible);
31783178
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.gender));
31793179
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.weight));
31803180
$r3$.ɵɵi18nExp($r3$.ɵɵbind(ctx.height));

packages/compiler-cli/test/compliance/r3_view_compiler_listener_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('compiler compliance: listen()', () => {
164164
}
165165
if (rf & 2) {
166166
$i0$.ɵɵselect(0);
167-
$i0$.ɵɵelementProperty(0, "ngIf", $i0$.ɵɵbind(ctx.showing));
167+
$i0$.ɵɵproperty("ngIf", ctx.showing);
168168
}
169169
}
170170
`;

packages/compiler-cli/test/compliance/r3_view_compiler_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ describe('r3_view_compiler', () => {
147147
}
148148
if (rf & 2) {
149149
$i0$.ɵɵselect(0);
150-
$i0$.ɵɵelementProperty(0, "@attr", …);
151-
$i0$.ɵɵelementProperty(0, "@binding", …);
150+
$i0$.ɵɵproperty("@attr", …);
151+
$i0$.ɵɵproperty("@binding", …);
152152
}
153153
}`;
154154
const result = compile(files, angularFiles);
@@ -179,7 +179,7 @@ describe('r3_view_compiler', () => {
179179
$i0$.ɵɵelementStart(0, "div");
180180
181181
$i0$.ɵɵselect(0);
182-
$i0$.ɵɵelementProperty(0, "@mySelector", …);
182+
$i0$.ɵɵproperty("@mySelector", …);
183183
}
184184
}`;
185185
const result = compile(files, angularFiles);

packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ describe('compiler compliance: styling', () => {
227227
}
228228
if (rf & 2) {
229229
$r3$.ɵɵselect(0);
230-
$r3$.ɵɵelementProperty(0, "@foo", $r3$.ɵɵbind(ctx.exp));
230+
$r3$.ɵɵproperty("@foo", ctx.exp);
231231
$r3$.ɵɵselect(1);
232-
$r3$.ɵɵelementProperty(1, "@bar", $r3$.ɵɵbind(undefined));
232+
$r3$.ɵɵproperty("@bar", undefined);
233233
$r3$.ɵɵselect(2);
234-
$r3$.ɵɵelementProperty(2, "@baz", $r3$.ɵɵbind(undefined));
234+
$r3$.ɵɵproperty("@baz", undefined);
235235
}
236236
},
237237
encapsulation: 2
@@ -289,7 +289,7 @@ describe('compiler compliance: styling', () => {
289289
$r3$.ɵɵelementEnd();
290290
} if (rf & 2) {
291291
$r3$.ɵɵselect(0);
292-
$r3$.ɵɵelementProperty(0, "@myAnimation", $r3$.ɵɵbind(ctx.exp));
292+
$r3$.ɵɵproperty("@myAnimation", ctx.exp);
293293
}
294294
},
295295
encapsulation: 2,

0 commit comments

Comments
 (0)