refactor(ivy): move directive, component and pipe factories to ngFactoryFn (#31953)

Reworks the compiler to output the factories for directives, components and pipes under a new static field called `ngFactoryFn`, instead of the usual `factory` property in their respective defs. This should eventually allow us to inject any kind of decorated class (e.g. a pipe).

**Note:** these changes are the first part of the refactor and they don't include injectables. I decided to leave injectables for a follow-up PR, because there's some more cases we need to handle when it comes to their factories. Furthermore, directives, components and pipes make up most of the compiler output tests that need to be refactored and it'll make follow-up PRs easier to review if the tests are cleaned up now.

This is part of the larger refactor for FW-1468.

PR Close #31953
This commit is contained in:
Kristiyan Kostadinov
2019-08-12 09:26:20 +03:00
committed by atscott
parent 14feb56139
commit c885178d5f
71 changed files with 894 additions and 675 deletions

View File

@ -44,7 +44,7 @@ describe('compiler compliance', () => {
// The factory should look like this:
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
// The template should look like this (where IDENT is a wild card for an identifier):
const template = `
@ -94,7 +94,7 @@ describe('compiler compliance', () => {
// The factory should look like this:
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
// The template should look like this (where IDENT is a wild card for an identifier):
const template = `
@ -142,7 +142,7 @@ describe('compiler compliance', () => {
// The factory should look like this:
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
// The template should look like this (where IDENT is a wild card for an identifier):
const template = `
@ -190,7 +190,7 @@ describe('compiler compliance', () => {
// The factory should look like this:
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
// The template should look like this (where IDENT is a wild card for an identifier):
const template = `
@ -306,7 +306,7 @@ describe('compiler compliance', () => {
};
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
const template = `
const $e0_attrs$ = [${AttributeMarker.Bindings}, "id"];
@ -361,7 +361,7 @@ describe('compiler compliance', () => {
///////////////
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
const template = `
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
@ -476,12 +476,9 @@ describe('compiler compliance', () => {
};
const factory =
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
const template = `
MyComponent.ngComponentDef = i0.ɵɵdefineComponent({type:MyComponent,selectors:[["my-component"]],
factory: function MyComponent_Factory(t){
return new (t || MyComponent)();
},
consts: 1,
vars: 2,
template: function MyComponent_Template(rf,ctx){
@ -536,7 +533,6 @@ describe('compiler compliance', () => {
ChildComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: ChildComponent,
selectors: [["child"]],
factory: function ChildComponent_Factory(t) { return new (t || ChildComponent)(); },
consts: 1,
vars: 0,
template: function ChildComponent_Template(rf, ctx) {
@ -547,15 +543,20 @@ describe('compiler compliance', () => {
encapsulation: 2
});`;
const ChildComponentFactory =
`ChildComponent.ngFactoryDef = function ChildComponent_Factory(t) { return new (t || ChildComponent)(); };`;
// SomeDirective definition should be:
const SomeDirectiveDefinition = `
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: SomeDirective,
selectors: [["", "some-directive", ""]],
factory: function SomeDirective_Factory(t) {return new (t || SomeDirective)(); }
selectors: [["", "some-directive", ""]]
});
`;
const SomeDirectiveFactory =
`SomeDirective.ngFactoryDef = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); };`;
// MyComponent definition should be:
const MyComponentDefinition = `
const $c1$ = ["some-directive", ""];
@ -563,7 +564,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 2,
vars: 0,
template: function MyComponent_Template(rf, ctx) {
@ -577,13 +577,18 @@ describe('compiler compliance', () => {
});
`;
const MyComponentFactory =
`MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };`;
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, ChildComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponentDefinition.ngComponentDef');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ngFactoryDef');
});
it('should support complex selectors', () => {
@ -608,25 +613,31 @@ describe('compiler compliance', () => {
const SomeDirectiveDefinition = `
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: SomeDirective,
selectors: [["div", "some-directive", "", 8, "foo", 3, "title", "", 9, "baz"]],
factory: function SomeDirective_Factory(t) {return new (t || SomeDirective)(); }
selectors: [["div", "some-directive", "", 8, "foo", 3, "title", "", 9, "baz"]]
});
`;
const SomeDirectiveFactory =
`SomeDirective.ngFactoryDef = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); };`;
// OtherDirective definition should be:
const OtherDirectiveDefinition = `
OtherDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: OtherDirective,
selectors: [["", 5, "span", "title", "", 9, "baz"]],
factory: function OtherDirective_Factory(t) {return new (t || OtherDirective)(); }
selectors: [["", 5, "span", "title", "", 9, "baz"]]
});
`;
const OtherDirectiveFactory =
`OtherDirective.ngFactoryDef = function OtherDirective_Factory(t) {return new (t || OtherDirective)(); };`;
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
expectEmit(source, OtherDirectiveDefinition, 'Incorrect OtherDirective.ngDirectiveDef');
expectEmit(source, OtherDirectiveFactory, 'Incorrect OtherDirective.ngFactoryDef');
});
it('should support components without selector', () => {
@ -650,7 +661,6 @@ describe('compiler compliance', () => {
EmptyOutletComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: EmptyOutletComponent,
selectors: [["ng-component"]],
factory: function EmptyOutletComponent_Factory(t) { return new (t || EmptyOutletComponent)(); },
consts: 1,
vars: 0,
template: function EmptyOutletComponent_Template(rf, ctx) {
@ -662,11 +672,16 @@ describe('compiler compliance', () => {
});
`;
const EmptyOutletComponentFactory =
`EmptyOutletComponent.ngFactoryDef = function EmptyOutletComponent_Factory(t) { return new (t || EmptyOutletComponent)(); };`;
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(
source, EmptyOutletComponentDefinition, 'Incorrect EmptyOutletComponent.ngComponentDef');
expectEmit(
source, EmptyOutletComponentFactory, 'Incorrect EmptyOutletComponent.ngFactoryDef');
});
it('should not treat ElementRef, ViewContainerRef, or ChangeDetectorRef specially when injecting',
@ -695,21 +710,23 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) {
return new (t || MyComponent)(
$r3$.ɵɵdirectiveInject($i$.ElementRef), $r3$.ɵɵdirectiveInject($i$.ViewContainerRef),
$r3$.ɵɵdirectiveInject($i$.ChangeDetectorRef));
},
consts: 0,
vars: 0,
template: function MyComponent_Template(rf, ctx) {},
encapsulation: 2
});`;
const MyComponentFactory = `MyComponent.ngFactoryDef = function MyComponent_Factory(t) {
return new (t || MyComponent)(
$r3$.ɵɵdirectiveInject($i$.ElementRef), $r3$.ɵɵdirectiveInject($i$.ViewContainerRef),
$r3$.ɵɵdirectiveInject($i$.ChangeDetectorRef));
};`;
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
});
it('should support structural directives', () => {
@ -740,9 +757,11 @@ describe('compiler compliance', () => {
const IfDirectiveDefinition = `
IfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: IfDirective,
selectors: [["", "if", ""]],
factory: function IfDirective_Factory(t) { return new (t || IfDirective)($r3$.ɵɵdirectiveInject($i$.TemplateRef)); }
selectors: [["", "if", ""]]
});`;
const IfDirectiveFactory =
`IfDirective.ngFactoryDef = function IfDirective_Factory(t) { return new (t || IfDirective)($r3$.ɵɵdirectiveInject($i$.TemplateRef)); };`;
const MyComponentDefinition = `
const $c1$ = ["foo", ""];
const $c2$ = [${AttributeMarker.Template}, "if"];
@ -763,7 +782,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 3,
vars: 0,
template: function MyComponent_Template(rf, ctx) {
@ -777,11 +795,16 @@ describe('compiler compliance', () => {
encapsulation: 2
});`;
const MyComponentFactory =
`MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };`;
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ngDirectiveDef');
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ngFactoryDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
});
describe('value composition', () => {
@ -826,7 +849,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) { return new (t || MyApp)(); },
consts: 1,
vars: 3,
template: function MyApp_Template(rf, ctx) {
@ -908,7 +930,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) { return new (t || MyApp)(); },
consts: 1,
vars: 11,
template: function MyApp_Template(rf, ctx) {
@ -971,7 +992,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) { return new (t || MyApp)(); },
consts: 1,
vars: 3,
template: function MyApp_Template(rf, ctx) {
@ -1039,7 +1059,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) { return new (t || MyApp)(); },
consts: 1,
vars: 8,
template: function MyApp_Template(rf, ctx) {
@ -1100,7 +1119,6 @@ describe('compiler compliance', () => {
SimpleComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: SimpleComponent,
selectors: [["simple"]],
factory: function SimpleComponent_Factory(t) { return new (t || SimpleComponent)(); },
ngContentSelectors: $c0$,
consts: 2,
vars: 0,
@ -1123,7 +1141,6 @@ describe('compiler compliance', () => {
ComplexComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: ComplexComponent,
selectors: [["complex"]],
factory: function ComplexComponent_Factory(t) { return new (t || ComplexComponent)(); },
ngContentSelectors: _c4,
consts: 4,
vars: 0,
@ -1179,7 +1196,6 @@ describe('compiler compliance', () => {
Cmp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: Cmp,
selectors: [["ng-component"]],
factory: function Cmp_Factory(t) { return new (t || Cmp)(); },
ngContentSelectors: $c1$,
consts: 3,
vars: 0,
@ -1368,9 +1384,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) {
return new(t || MyApp)();
},
consts: 2,
vars: 0,
template: function MyApp_Template(rf, ctx) {
@ -1423,9 +1436,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) {
return new(t || MyApp)();
},
consts: 2,
vars: 0,
template: function MyApp_Template(rf, ctx) {
@ -1489,7 +1499,6 @@ describe('compiler compliance', () => {
ViewQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: ViewQueryComponent,
selectors: [["view-query-component"]],
factory: function ViewQueryComponent_Factory(t) { return new (t || ViewQueryComponent)(); },
viewQuery: function ViewQueryComponent_Query(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵviewQuery(SomeDirective, true);
@ -1600,7 +1609,6 @@ describe('compiler compliance', () => {
ViewQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: ViewQueryComponent,
selectors: [["view-query-component"]],
factory: function ViewQueryComponent_Factory(t) { return new (t || ViewQueryComponent)(); },
viewQuery: function ViewQueryComponent_Query(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵstaticViewQuery(SomeDirective, true);
@ -1727,9 +1735,6 @@ describe('compiler compliance', () => {
ContentQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: ContentQueryComponent,
selectors: [["content-query-component"]],
factory: function ContentQueryComponent_Factory(t) {
return new (t || ContentQueryComponent)();
},
contentQueries: function ContentQueryComponent_ContentQueries(rf, ctx, dirIndex) {
if (rf & 1) {
$r3$.ɵɵcontentQuery(dirIndex, SomeDirective, true);
@ -1849,9 +1854,6 @@ describe('compiler compliance', () => {
ContentQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: ContentQueryComponent,
selectors: [["content-query-component"]],
factory: function ContentQueryComponent_Factory(t) {
return new (t || ContentQueryComponent)();
},
contentQueries: function ContentQueryComponent_ContentQueries(rf, ctx, dirIndex) {
if (rf & 1) {
$r3$.ɵɵstaticContentQuery(dirIndex, SomeDirective, true);
@ -1988,19 +1990,25 @@ describe('compiler compliance', () => {
MyPipe.ngPipeDef = $r3$.ɵɵdefinePipe({
name: "myPipe",
type: MyPipe,
factory: function MyPipe_Factory(t) { return new (t || MyPipe)(); },
pure: false
});
`;
const MyPipengFactoryDef = `
MyPipe.ngFactoryDef = function MyPipe_Factory(t) { return new (t || MyPipe)(); };
`;
const MyPurePipeDefinition = `
MyPurePipe.ngPipeDef = $r3$.ɵɵdefinePipe({
name: "myPurePipe",
type: MyPurePipe,
factory: function MyPurePipe_Factory(t) { return new (t || MyPurePipe)(); },
pure: true
});`;
const MyPurePipengFactoryDef = `
MyPurePipe.ngFactoryDef = function MyPurePipe_Factory(t) { return new (t || MyPurePipe)(); };
`;
const MyAppDefinition = `
const $c0$ = function ($a0$) {
return [$a0$, 1, 2, 3, 4, 5];
@ -2009,7 +2017,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) { return new (t || MyApp)(); },
consts: 7,
vars: 20,
template: function MyApp_Template(rf, ctx) {
@ -2037,7 +2044,9 @@ describe('compiler compliance', () => {
const source = result.source;
expectEmit(source, MyPipeDefinition, 'Invalid pipe definition');
expectEmit(source, MyPipengFactoryDef, 'Invalid pipe factory function');
expectEmit(source, MyPurePipeDefinition, 'Invalid pure pipe definition');
expectEmit(source, MyPurePipengFactoryDef, 'Invalid pure pipe factory function');
expectEmit(source, MyAppDefinition, 'Invalid MyApp definition');
});
@ -2075,7 +2084,6 @@ describe('compiler compliance', () => {
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
factory: function MyApp_Factory(t) { return new (t || MyApp)(); },
consts: 6,
vars: 27,
template: function MyApp_Template(rf, ctx) {
@ -2148,24 +2156,32 @@ describe('compiler compliance', () => {
MyPipe.ngPipeDef = $r3$.ɵɵdefinePipe({
name: "myPipe",
type: MyPipe,
factory: function MyPipe_Factory(t) { return new (t || MyPipe)($r3$.ɵɵinjectPipeChangeDetectorRef()); },
pure: true
});
`;
const MyPipeFactory = `
MyPipe.ngFactoryDef = function MyPipe_Factory(t) { return new (t || MyPipe)($r3$.ɵɵinjectPipeChangeDetectorRef()); };
`;
const MyOtherPipeDefinition = `
MyOtherPipe.ngPipeDef = $r3$.ɵɵdefinePipe({
name: "myOtherPipe",
type: MyOtherPipe,
factory: function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵinjectPipeChangeDetectorRef(8)); },
pure: true
});`;
const MyOtherPipeFactory = `
MyOtherPipe.ngFactoryDef = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵinjectPipeChangeDetectorRef(8)); };
`;
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyPipeDefinition, 'Invalid pipe definition');
expectEmit(source, MyPipeFactory, 'Invalid pipe factory function');
expectEmit(source, MyOtherPipeDefinition, 'Invalid alternate pipe definition');
expectEmit(source, MyOtherPipeFactory, 'Invalid alternate pipe factory function');
});
});
@ -2191,7 +2207,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 3,
vars: 1,
template: function MyComponent_Template(rf, ctx) {
@ -2288,7 +2303,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 6,
vars: 1,
template: function MyComponent_Template(rf, ctx) {
@ -2434,7 +2448,6 @@ describe('compiler compliance', () => {
LifecycleComp.ngComponentDef = $r3$.ɵɵdefineComponent({
type: LifecycleComp,
selectors: [["lifecycle-comp"]],
factory: function LifecycleComp_Factory(t) { return new (t || LifecycleComp)(); },
inputs: {nameMin: ["name", "nameMin"]},
features: [$r3$.ɵɵNgOnChangesFeature()],
consts: 0,
@ -2447,7 +2460,6 @@ describe('compiler compliance', () => {
SimpleLayout.ngComponentDef = $r3$.ɵɵdefineComponent({
type: SimpleLayout,
selectors: [["simple-layout"]],
factory: function SimpleLayout_Factory(t) { return new (t || SimpleLayout)(); },
consts: 2,
vars: 2,
template: function SimpleLayout_Template(rf, ctx) {
@ -2556,14 +2568,16 @@ describe('compiler compliance', () => {
ForOfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: ForOfDirective,
selectors: [["", "forOf", ""]],
factory: function ForOfDirective_Factory(t) {
return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject(ViewContainerRef), $r3$.ɵɵdirectiveInject(TemplateRef));
},
features: [$r3$.ɵɵNgOnChangesFeature()],
inputs: {forOf: "forOf"}
});
`;
const ForDirectiveFactory =
`ForOfDirective.ngFactoryDef = function ForOfDirective_Factory(t) {
return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject(ViewContainerRef), $r3$.ɵɵdirectiveInject(TemplateRef));
};`;
const MyComponentDefinition = `
const $t1_attrs$ = [${AttributeMarker.Template}, "for", "forOf"];
function MyComponent__svg_g_1_Template(rf, ctx) {
@ -2578,7 +2592,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 2,
vars: 1,
template: function MyComponent_Template(rf, ctx){
@ -2603,6 +2616,7 @@ describe('compiler compliance', () => {
// TODO(benlesh): Enforce this when the directives are specified
// expectEmit(source, ForDirectiveDefinition, 'Invalid directive definition');
// expectEmit(source, ForDirectiveFactory, 'Invalid directive factory');
expectEmit(source, MyComponentDefinition, 'Invalid component definition');
});
@ -2635,14 +2649,17 @@ describe('compiler compliance', () => {
ForOfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: ForOfDirective,
selectors: [["", "forOf", ""]],
factory: function ForOfDirective_Factory(t) {
return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject(ViewContainerRef), $r3$.ɵɵdirectiveInject(TemplateRef));
},
features: [$r3$.ɵɵNgOnChangesFeature()],
inputs: {forOf: "forOf"}
});
`;
const ForDirectiveFactory = `
ForOfDirective.ngFactoryDef = function ForOfDirective_Factory(t) {
return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject(ViewContainerRef), $r3$.ɵɵdirectiveInject(TemplateRef));
};
`;
const MyComponentDefinition = `
const $t1_attrs$ = [${AttributeMarker.Template}, "for", "forOf"];
function MyComponent_li_1_Template(rf, ctx) {
@ -2661,7 +2678,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 2,
vars: 1,
template: function MyComponent_Template(rf, ctx) {
@ -2685,6 +2701,7 @@ describe('compiler compliance', () => {
// TODO(chuckj): Enforce this when the directives are specified
// expectEmit(source, ForDirectiveDefinition, 'Invalid directive definition');
// expectEmit(source, ForDirectiveFactory, 'Invalid directive factory');
expectEmit(source, MyComponentDefinition, 'Invalid component definition');
});
@ -2765,7 +2782,6 @@ describe('compiler compliance', () => {
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); },
consts: 2,
vars: 1,
template: function MyComponent_Template(rf, ctx) {
@ -2883,7 +2899,6 @@ describe('compiler compliance', () => {
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
type: SomeDirective,
selectors: [["", "some-directive", ""]],
factory: function SomeDirective_Factory(t) {return new (t || SomeDirective)(); },
exportAs: ["someDir", "otherDir"]
});
`;