refactor(core): rename ngFactoryDef to ɵfac (#33116)

Factory defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngFactoryDef to fac. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngPipeDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close #33116
This commit is contained in:
Kara Erickson
2019-10-11 14:18:45 -07:00
committed by Miško Hevery
parent c3aaa5211e
commit 0de2a5e408
45 changed files with 232 additions and 245 deletions

View File

@ -33,7 +33,7 @@ describe('iv perf test', () => {
it(`${iteration}. create ${count} divs in Render3`, () => {
class Component {
static ngFactoryDef = () => new Component;
static ɵfac = () => new Component;
static ɵcmp = ɵɵdefineComponent({
type: Component,
selectors: [['div']],

View File

@ -25,7 +25,7 @@ describe('change detection', () => {
doCheckCount = 0;
ngDoCheck(): void { this.doCheckCount++; }
static ngFactoryDef = () => new MyComponent();
static ɵfac = () => new MyComponent();
static ɵcmp = ɵɵdefineComponent({
type: MyComponent,
selectors: [['my-comp']],
@ -101,7 +101,7 @@ describe('change detection', () => {
onClick() {}
static ngFactoryDef = () => comp = new MyComponent();
static ɵfac = () => comp = new MyComponent();
static ɵcmp = ɵɵdefineComponent({
type: MyComponent,
selectors: [['my-comp']],
@ -139,7 +139,7 @@ describe('change detection', () => {
onClick() {}
static ngFactoryDef = () => comp = new ManualComponent();
static ɵfac = () => comp = new ManualComponent();
static ɵcmp = ɵɵdefineComponent({
type: ManualComponent,
selectors: [['manual-comp']],
@ -175,7 +175,7 @@ describe('change detection', () => {
class ManualApp {
name: string = 'Nancy';
static ngFactoryDef = () => new ManualApp();
static ɵfac = () => new ManualApp();
static ɵcmp = ɵɵdefineComponent({
type: ManualApp,
selectors: [['manual-app']],
@ -230,7 +230,7 @@ describe('change detection', () => {
doCheckCount = 0;
ngDoCheck(): void { this.doCheckCount++; }
static ngFactoryDef = () => parent = new ButtonParent();
static ɵfac = () => parent = new ButtonParent();
static ɵcmp = ɵɵdefineComponent({
type: ButtonParent,
selectors: [['button-parent']],
@ -307,7 +307,7 @@ describe('change detection', () => {
return 'works';
}
static ngFactoryDef = () => new MyComponent();
static ɵfac = () => new MyComponent();
static ɵcmp = ɵɵdefineComponent({
type: MyComponent,
selectors: [['my-comp']],

View File

@ -25,7 +25,7 @@ NgForOf.ɵdir = ɵɵdefineDirective({
}
});
NgForOf.ngFactoryDef = () => new NgForOfDef(
NgForOf.ɵfac = () => new NgForOfDef(
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any),
ɵɵdirectiveInject(IterableDiffers));
@ -35,7 +35,7 @@ NgIf.ɵdir = ɵɵdefineDirective({
inputs: {ngIf: 'ngIf', ngIfThen: 'ngIfThen', ngIfElse: 'ngIfElse'}
});
NgIf.ngFactoryDef = () =>
NgIf.ɵfac = () =>
new NgIfDef(ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any));
NgTemplateOutlet.ɵdir = ɵɵdefineDirective({
@ -46,5 +46,4 @@ NgTemplateOutlet.ɵdir = ɵɵdefineDirective({
{ngTemplateOutlet: 'ngTemplateOutlet', ngTemplateOutletContext: 'ngTemplateOutletContext'}
});
NgTemplateOutlet.ngFactoryDef = () =>
new NgTemplateOutletDef(ɵɵdirectiveInject(ViewContainerRef as any));
NgTemplateOutlet.ɵfac = () => new NgTemplateOutletDef(ɵɵdirectiveInject(ViewContainerRef as any));

View File

@ -20,7 +20,7 @@ describe('ComponentFactory', () => {
describe('constructor()', () => {
it('should correctly populate default properties', () => {
class TestComponent {
static ngFactoryDef = () => new TestComponent();
static ɵfac = () => new TestComponent();
static ɵcmp = ɵɵdefineComponent({
type: TestComponent,
selectors: [['test', 'foo'], ['bar']],
@ -41,7 +41,7 @@ describe('ComponentFactory', () => {
it('should correctly populate defined properties', () => {
class TestComponent {
static ngFactoryDef = () => new TestComponent();
static ɵfac = () => new TestComponent();
static ɵcmp = ɵɵdefineComponent({
type: TestComponent,
encapsulation: ViewEncapsulation.None,
@ -89,7 +89,7 @@ describe('ComponentFactory', () => {
createRenderer3Spy = spyOn(domRendererFactory3, 'createRenderer').and.callThrough();
class TestComponent {
static ngFactoryDef = () => new TestComponent();
static ɵfac = () => new TestComponent();
static ɵcmp = ɵɵdefineComponent({
type: TestComponent,
encapsulation: ViewEncapsulation.None,

View File

@ -21,7 +21,7 @@ describe('component', () => {
increment() { this.count++; }
static ngFactoryDef = () => new CounterComponent;
static ɵfac = () => new CounterComponent;
static ɵcmp = ɵɵdefineComponent({
type: CounterComponent,
encapsulation: ViewEncapsulation.None,
@ -71,7 +71,7 @@ describe('component', () => {
}
class MyComponent {
constructor(public myService: MyService) {}
static ngFactoryDef = () => new MyComponent(ɵɵdirectiveInject(MyService));
static ɵfac = () => new MyComponent(ɵɵdirectiveInject(MyService));
static ɵcmp = ɵɵdefineComponent({
type: MyComponent,
encapsulation: ViewEncapsulation.None,
@ -115,7 +115,7 @@ describe('component', () => {
// @Input
name = '';
static ngFactoryDef = () => new Comp();
static ɵfac = () => new Comp();
static ɵcmp = ɵɵdefineComponent({
type: Comp,
selectors: [['comp']],
@ -169,7 +169,7 @@ it('should not invoke renderer destroy method for embedded views', () => {
class Comp {
visible = true;
static ngFactoryDef =
static ɵfac =
() => {
comp = new Comp();
return comp;
@ -247,7 +247,7 @@ describe('component with a container', () => {
class WrapperComponent {
// TODO(issue/24571): remove '!'.
items !: string[];
static ngFactoryDef = () => new WrapperComponent;
static ɵfac = () => new WrapperComponent;
static ɵcmp = ɵɵdefineComponent({
type: WrapperComponent,
encapsulation: ViewEncapsulation.None,
@ -324,7 +324,7 @@ describe('recursive components', () => {
ngOnDestroy() { events.push('destroy' + this.data.value); }
static ngFactoryDef = () => new TreeComponent();
static ɵfac = () => new TreeComponent();
static ɵcmp = ɵɵdefineComponent({
type: TreeComponent,
encapsulation: ViewEncapsulation.None,
@ -389,7 +389,7 @@ describe('recursive components', () => {
ngOnDestroy() { events.push('destroy' + this.data.value); }
static ngFactoryDef = () => new NgIfTree();
static ɵfac = () => new NgIfTree();
static ɵcmp = ɵɵdefineComponent({
type: NgIfTree,
encapsulation: ViewEncapsulation.None,
@ -530,7 +530,7 @@ describe('recursive components', () => {
class TestInputsComponent {
// TODO(issue/24571): remove '!'.
minifiedName !: string;
static ngFactoryDef = () => new TestInputsComponent();
static ɵfac = () => new TestInputsComponent();
static ɵcmp = ɵɵdefineComponent({
type: TestInputsComponent,
encapsulation: ViewEncapsulation.None,

View File

@ -693,7 +693,7 @@ describe('JS control flow', () => {
// Intentionally duplicating the templates in test below so we are
// testing the behavior on firstTemplatePass for each of these tests
class Comp {
static ngFactoryDef =
static ɵfac =
() => {
log.push('comp!');
return new Comp();
@ -712,7 +712,7 @@ describe('JS control flow', () => {
condition = true;
condition2 = true;
static ngFactoryDef = () => new App();
static ɵfac = () => new App();
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app']],
@ -763,7 +763,7 @@ describe('JS control flow', () => {
// Intentionally duplicating the templates from above so we are
// testing the behavior on firstTemplatePass for each of these tests
class Comp {
static ngFactoryDef =
static ɵfac =
() => {
log.push('comp!');
return new Comp();
@ -782,7 +782,7 @@ describe('JS control flow', () => {
condition = false;
condition2 = true;
static ngFactoryDef = () => new App();
static ɵfac = () => new App();
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app']],

View File

@ -28,7 +28,7 @@ describe('di', () => {
class DirB {
value = 'DirB';
static ngFactoryDef = () => new DirB();
static ɵfac = () => new DirB();
static ɵdir =
ɵɵdefineDirective({selectors: [['', 'dirB', '']], type: DirB, inputs: {value: 'value'}});
}
@ -39,7 +39,7 @@ describe('di', () => {
// TODO(issue/24571): remove '!'.
value !: string;
static ngFactoryDef = () => new DirB();
static ɵfac = () => new DirB();
static ɵdir =
ɵɵdefineDirective({type: DirB, selectors: [['', 'dirB', '']], inputs: {value: 'dirB'}});
}
@ -50,7 +50,7 @@ describe('di', () => {
class DirA {
constructor(@Optional() public dirB: DirB|null) {}
static ngFactoryDef =
static ɵfac =
() => {
dirA = new DirA(ɵɵdirectiveInject(DirB, InjectFlags.Optional));
return dirA;
@ -81,7 +81,7 @@ describe('di', () => {
class DirA {
constructor(@Self() public dirB: DirB) {}
static ngFactoryDef = () => dirA = new DirA(ɵɵdirectiveInject(DirB, InjectFlags.Self));
static ɵfac = () => dirA = new DirA(ɵɵdirectiveInject(DirB, InjectFlags.Self));
static ɵdir = ɵɵdefineDirective({type: DirA, selectors: [['', 'dirA', '']]});
}
@ -117,7 +117,7 @@ describe('di', () => {
class MyComp {
constructor(public renderer: Renderer2) {}
static ngFactoryDef = () => new MyComp(ɵɵdirectiveInject(Renderer2 as any));
static ɵfac = () => new MyComp(ɵɵdirectiveInject(Renderer2 as any));
static ɵcmp = ɵɵdefineComponent({
type: MyComp,
selectors: [['my-comp']],

View File

@ -240,7 +240,7 @@ describe('instructions', () => {
class NestedLoops {
rows = [['a', 'b'], ['A', 'B'], ['a', 'b'], ['A', 'B']];
static ngFactoryDef = function ToDoAppComponent_Factory() { return new NestedLoops(); };
static ɵfac = function ToDoAppComponent_Factory() { return new NestedLoops(); };
static ɵcmp = ɵɵdefineComponent({
type: NestedLoops,
selectors: [['nested-loops']],

View File

@ -117,7 +117,7 @@ describe('render3 integration test', () => {
// TODO(issue/24571): remove '!'.
afterTree !: Tree;
static ngFactoryDef = () => new ChildComponent;
static ɵfac = () => new ChildComponent;
static ɵcmp = ɵɵdefineComponent({
selectors: [['child']],
type: ChildComponent,
@ -199,7 +199,7 @@ describe('render3 integration test', () => {
describe('component styles', () => {
it('should pass in the component styles directly into the underlying renderer', () => {
class StyledComp {
static ngFactoryDef = () => new StyledComp();
static ɵfac = () => new StyledComp();
static ɵcmp = ɵɵdefineComponent({
type: StyledComp,
styles: ['div { color: red; }'],
@ -227,7 +227,7 @@ describe('component animations', () => {
const animB = {name: 'b'};
class AnimComp {
static ngFactoryDef = () => new AnimComp();
static ɵfac = () => new AnimComp();
static ɵcmp = ɵɵdefineComponent({
type: AnimComp,
decls: 0,
@ -254,7 +254,7 @@ describe('component animations', () => {
it('should include animations in the renderType data array even if the array is empty', () => {
class AnimComp {
static ngFactoryDef = () => new AnimComp();
static ɵfac = () => new AnimComp();
static ɵcmp = ɵɵdefineComponent({
type: AnimComp,
decls: 0,
@ -274,7 +274,7 @@ describe('component animations', () => {
it('should allow [@trigger] bindings to be picked up by the underlying renderer', () => {
class AnimComp {
static ngFactoryDef = () => new AnimComp();
static ɵfac = () => new AnimComp();
static ɵcmp = ɵɵdefineComponent({
type: AnimComp,
decls: 1,
@ -311,7 +311,7 @@ describe('component animations', () => {
it('should allow creation-level [@trigger] properties to be picked up by the underlying renderer',
() => {
class AnimComp {
static ngFactoryDef = () => new AnimComp();
static ɵfac = () => new AnimComp();
static ɵcmp = ɵɵdefineComponent({
type: AnimComp,
decls: 1,
@ -345,7 +345,7 @@ describe('component animations', () => {
// it('should allow host binding animations to be picked up and rendered', () => {
// class ChildCompWithAnim {
// static ngFactoryDef = () => new ChildCompWithAnim();
// static ɵfac = () => new ChildCompWithAnim();
// static ɵdir = ɵɵdefineDirective({
// type: ChildCompWithAnim,
// selectors: [['child-comp-with-anim']],
@ -360,7 +360,7 @@ describe('component animations', () => {
// }
// class ParentComp {
// static ngFactoryDef = () => new ParentComp();
// static ɵfac = () => new ParentComp();
// static ɵcmp = ɵɵdefineComponent({
// type: ParentComp,
// decls: 1,
@ -390,7 +390,7 @@ describe('component animations', () => {
describe('element discovery', () => {
it('should only monkey-patch immediate child nodes in a component', () => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -422,7 +422,7 @@ describe('element discovery', () => {
it('should only monkey-patch immediate child nodes in a sub component', () => {
class ChildComp {
static ngFactoryDef = () => new ChildComp();
static ɵfac = () => new ChildComp();
static ɵcmp = ɵɵdefineComponent({
type: ChildComp,
selectors: [['child-comp']],
@ -439,7 +439,7 @@ describe('element discovery', () => {
}
class ParentComp {
static ngFactoryDef = () => new ParentComp();
static ɵfac = () => new ParentComp();
static ɵcmp = ɵɵdefineComponent({
type: ParentComp,
selectors: [['parent-comp']],
@ -472,7 +472,7 @@ describe('element discovery', () => {
it('should only monkey-patch immediate child nodes in an embedded template container', () => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -522,7 +522,7 @@ describe('element discovery', () => {
it('should return a context object from a given dom node', () => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -560,7 +560,7 @@ describe('element discovery', () => {
it('should cache the element context on a element was pre-emptively monkey-patched', () => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -592,7 +592,7 @@ describe('element discovery', () => {
it('should cache the element context on an intermediate element that isn\'t pre-emptively monkey-patched',
() => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -625,7 +625,7 @@ describe('element discovery', () => {
it('should be able to pull in element context data even if the element is decorated using styling',
() => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -673,7 +673,7 @@ describe('element discovery', () => {
</section>
*/
class ProjectorComp {
static ngFactoryDef = () => new ProjectorComp();
static ɵfac = () => new ProjectorComp();
static ɵcmp = ɵɵdefineComponent({
type: ProjectorComp,
selectors: [['projector-comp']],
@ -696,7 +696,7 @@ describe('element discovery', () => {
}
class ParentComp {
static ngFactoryDef = () => new ParentComp();
static ɵfac = () => new ParentComp();
static ɵcmp = ɵɵdefineComponent({
type: ParentComp,
selectors: [['parent-comp']],
@ -770,7 +770,7 @@ describe('element discovery', () => {
it('should return `null` when an element context is retrieved that is a DOM node that was not created by Angular',
() => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -797,7 +797,7 @@ describe('element discovery', () => {
it('should by default monkey-patch the bootstrap component with context details', () => {
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -836,22 +836,22 @@ describe('element discovery', () => {
let myDir3Instance: MyDir2|null = null;
class MyDir1 {
static ngFactoryDef = () => myDir1Instance = new MyDir1();
static ɵfac = () => myDir1Instance = new MyDir1();
static ɵdir = ɵɵdefineDirective({type: MyDir1, selectors: [['', 'my-dir-1', '']]});
}
class MyDir2 {
static ngFactoryDef = () => myDir2Instance = new MyDir2();
static ɵfac = () => myDir2Instance = new MyDir2();
static ɵdir = ɵɵdefineDirective({type: MyDir2, selectors: [['', 'my-dir-2', '']]});
}
class MyDir3 {
static ngFactoryDef = () => myDir3Instance = new MyDir2();
static ɵfac = () => myDir3Instance = new MyDir2();
static ɵdir = ɵɵdefineDirective({type: MyDir3, selectors: [['', 'my-dir-3', '']]});
}
class StructuredComp {
static ngFactoryDef = () => new StructuredComp();
static ɵfac = () => new StructuredComp();
static ɵcmp = ɵɵdefineComponent({
type: StructuredComp,
selectors: [['structured-comp']],
@ -917,17 +917,17 @@ describe('element discovery', () => {
let childComponentInstance: ChildComp|null = null;
class MyDir1 {
static ngFactoryDef = () => myDir1Instance = new MyDir1();
static ɵfac = () => myDir1Instance = new MyDir1();
static ɵdir = ɵɵdefineDirective({type: MyDir1, selectors: [['', 'my-dir-1', '']]});
}
class MyDir2 {
static ngFactoryDef = () => myDir2Instance = new MyDir2();
static ɵfac = () => myDir2Instance = new MyDir2();
static ɵdir = ɵɵdefineDirective({type: MyDir2, selectors: [['', 'my-dir-2', '']]});
}
class ChildComp {
static ngFactoryDef = () => childComponentInstance = new ChildComp();
static ɵfac = () => childComponentInstance = new ChildComp();
static ɵcmp = ɵɵdefineComponent({
type: ChildComp,
selectors: [['child-comp']],
@ -942,7 +942,7 @@ describe('element discovery', () => {
}
class ParentComp {
static ngFactoryDef = () => new ParentComp();
static ɵfac = () => new ParentComp();
static ɵcmp = ɵɵdefineComponent({
type: ParentComp,
selectors: [['parent-comp']],
@ -1005,7 +1005,7 @@ describe('element discovery', () => {
it('should monkey-patch sub components with the view data and then replace them with the context result once a lookup occurs',
() => {
class ChildComp {
static ngFactoryDef = () => new ChildComp();
static ɵfac = () => new ChildComp();
static ɵcmp = ɵɵdefineComponent({
type: ChildComp,
selectors: [['child-comp']],
@ -1022,7 +1022,7 @@ describe('element discovery', () => {
}
class ParentComp {
static ngFactoryDef = () => new ParentComp();
static ɵfac = () => new ParentComp();
static ɵcmp = ɵɵdefineComponent({
type: ParentComp,
selectors: [['parent-comp']],
@ -1066,7 +1066,7 @@ describe('element discovery', () => {
describe('sanitization', () => {
it('should sanitize data using the provided sanitization interface', () => {
class SanitizationComp {
static ngFactoryDef = () => new SanitizationComp();
static ɵfac = () => new SanitizationComp();
static ɵcmp = ɵɵdefineComponent({
type: SanitizationComp,
selectors: [['sanitize-this']],
@ -1108,7 +1108,7 @@ describe('sanitization', () => {
// @HostBinding()
cite: any = 'http://cite-dir-value';
static ngFactoryDef = () => hostBindingDir = new UnsafeUrlHostBindingDir();
static ɵfac = () => hostBindingDir = new UnsafeUrlHostBindingDir();
static ɵdir = ɵɵdefineDirective({
type: UnsafeUrlHostBindingDir,
selectors: [['', 'unsafeUrlHostBindingDir', '']],
@ -1124,7 +1124,7 @@ describe('sanitization', () => {
}
class SimpleComp {
static ngFactoryDef = () => new SimpleComp();
static ɵfac = () => new SimpleComp();
static ɵcmp = ɵɵdefineComponent({
type: SimpleComp,
selectors: [['sanitize-this']],

View File

@ -34,7 +34,7 @@ ivyEnabled && describe('render3 jit', () => {
const SomeCmpAny = SomeCmp as any;
expect(SomeCmpAny.ɵcmp).toBeDefined();
expect(SomeCmpAny.ngFactoryDef() instanceof SomeCmp).toBe(true);
expect(SomeCmpAny.ɵfac() instanceof SomeCmp).toBe(true);
});
it('compiles an injectable with a type provider', () => {
@ -242,7 +242,7 @@ ivyEnabled && describe('render3 jit', () => {
}
const pipeDef = (P as any).ngPipeDef as PipeDef<P>;
const pipeFactory = (P as any).ngFactoryDef as FactoryFn<P>;
const pipeFactory = (P as any).ɵfac as FactoryFn<P>;
expect(pipeDef.name).toBe('test-pipe');
expect(pipeDef.pure).toBe(false, 'pipe should not be pure');
expect(pipeFactory() instanceof P)

View File

@ -55,7 +55,7 @@ describe('lifecycles', () => {
events.push(`${name}${this.val}`);
}
static ngFactoryDef = () => new Component();
static ɵfac = () => new Component();
static ɵcmp = ɵɵdefineComponent({
type: Component,
selectors: [[name]],
@ -70,7 +70,7 @@ describe('lifecycles', () => {
class Directive {
ngOnInit() { events.push('dir'); }
static ngFactoryDef = () => new Directive();
static ɵfac = () => new Directive();
static ɵdir = ɵɵdefineDirective({type: Directive, selectors: [['', 'dir', '']]});
}

View File

@ -27,7 +27,7 @@ describe('event listeners', () => {
onClick() { this.counter++; }
static ngFactoryDef =
static ɵfac =
() => {
let comp = new MyComp();
comps.push(comp);
@ -60,7 +60,7 @@ describe('event listeners', () => {
/* @HostListener('body:click') */
onBodyClick() { events.push('component - body:click'); }
static ngFactoryDef =
static ɵfac =
() => {
let comp = new MyCompWithGlobalListeners();
comps.push(comp);
@ -98,9 +98,7 @@ describe('event listeners', () => {
/* @HostListener('body:click') */
onBodyClick() { events.push('directive - body:click'); }
static ngFactoryDef = function HostListenerDir_Factory() {
return new GlobalHostListenerDir();
};
static ɵfac = function HostListenerDir_Factory() { return new GlobalHostListenerDir(); };
static ɵdir = ɵɵdefineDirective({
type: GlobalHostListenerDir,
selectors: [['', 'hostListenerDir', '']],
@ -134,7 +132,7 @@ describe('event listeners', () => {
return this.handlerReturnValue;
}
static ngFactoryDef = () => new PreventDefaultComp();
static ɵfac = () => new PreventDefaultComp();
static ɵcmp = ɵɵdefineComponent({
type: PreventDefaultComp,
selectors: [['prevent-default-comp']],
@ -325,7 +323,7 @@ describe('event listeners', () => {
onClick() { this.counter++; }
static ngFactoryDef = () => new AppComp();
static ɵfac = () => new AppComp();
static ɵcmp = ɵɵdefineComponent({
type: AppComp,
selectors: [['app-comp']],
@ -386,7 +384,7 @@ describe('event listeners', () => {
onClick(index: number) { this.counters[index]++; }
static ngFactoryDef = () => new AppComp();
static ɵfac = () => new AppComp();
static ɵcmp = ɵɵdefineComponent({
type: AppComp,
selectors: [['app-comp']],
@ -450,7 +448,7 @@ describe('event listeners', () => {
onClick(index: number) { this.counters[index]++; }
static ngFactoryDef = () => new AppComp();
static ɵfac = () => new AppComp();
static ɵcmp = ɵɵdefineComponent({
type: AppComp,
selectors: [['app-comp']],
@ -529,7 +527,7 @@ describe('event listeners', () => {
/* @HostListener('click') */
onClick() { events.push('click!'); }
static ngFactoryDef = () => { return new MyComp(); };
static ɵfac = () => { return new MyComp(); };
static ɵcmp = ɵɵdefineComponent({
type: MyComp,
selectors: [['comp']],
@ -580,7 +578,7 @@ describe('event listeners', () => {
/* @HostListener('click') */
onClick() { events.push('click!'); }
static ngFactoryDef = function HostListenerDir_Factory() { return new HostListenerDir(); };
static ɵfac = function HostListenerDir_Factory() { return new HostListenerDir(); };
static ɵdir = ɵɵdefineDirective({
type: HostListenerDir,
selectors: [['', 'hostListenerDir', '']],
@ -632,7 +630,7 @@ describe('event listeners', () => {
onClick(a: any, b: any) { this.counter += a + b; }
static ngFactoryDef = () => new MyComp();
static ɵfac = () => new MyComp();
static ɵcmp = ɵɵdefineComponent({
type: MyComp,
selectors: [['comp']],
@ -913,7 +911,7 @@ describe('event listeners', () => {
onClick(comp: any) { this.comp = comp; }
static ngFactoryDef = () => new App();
static ɵfac = () => new App();
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app']],

View File

@ -21,7 +21,7 @@ describe('outputs', () => {
change = new EventEmitter();
resetStream = new EventEmitter();
static ngFactoryDef = () => buttonToggle = new ButtonToggle();
static ɵfac = () => buttonToggle = new ButtonToggle();
static ɵcmp = ɵɵdefineComponent({
type: ButtonToggle,
selectors: [['button-toggle']],
@ -37,7 +37,7 @@ describe('outputs', () => {
class OtherDir {
changeStream = new EventEmitter();
static ngFactoryDef = () => otherDir = new OtherDir;
static ɵfac = () => otherDir = new OtherDir;
static ɵdir = ɵɵdefineDirective(
{type: OtherDir, selectors: [['', 'otherDir', '']], outputs: {changeStream: 'change'}});
}

View File

@ -29,7 +29,7 @@ describe('pipe', () => {
class WrappingPipe implements PipeTransform {
transform(value: any) { return new WrappedValue('Bar'); }
static ngFactoryDef = function WrappingPipe_Factory() { return new WrappingPipe(); };
static ɵfac = function WrappingPipe_Factory() { return new WrappingPipe(); };
static ngPipeDef = ɵɵdefinePipe({name: 'wrappingPipe', type: WrappingPipe, pure: false});
}

View File

@ -867,7 +867,7 @@ describe('providers', () => {
class Repeated {
constructor(private s: String, private n: Number) {}
static ngFactoryDef =
static ɵfac =
() => { return new Repeated(ɵɵdirectiveInject(String), ɵɵdirectiveInject(Number)); }
static ɵcmp = ɵɵdefineComponent({
@ -900,7 +900,7 @@ describe('providers', () => {
[{provide: String, useValue: 'foo'}, {provide: Number, useValue: 2, multi: true}],
})
class ComponentWithProviders {
static ngFactoryDef = () => new ComponentWithProviders();
static ɵfac = () => new ComponentWithProviders();
static ɵcmp = ɵɵdefineComponent({
type: ComponentWithProviders,
selectors: [['component-with-providers']],
@ -953,7 +953,7 @@ describe('providers', () => {
class Repeated {
constructor(private s: String, private n: Number) {}
static ngFactoryDef =
static ɵfac =
() => { return new Repeated(ɵɵdirectiveInject(String), ɵɵdirectiveInject(Number)); }
static ɵcmp = ɵɵdefineComponent({
@ -989,7 +989,7 @@ describe('providers', () => {
viewProviders: [{provide: toString, useValue: 'foo'}],
})
class ComponentWithProviders {
static ngFactoryDef = () => new ComponentWithProviders();
static ɵfac = () => new ComponentWithProviders();
static ɵcmp = ɵɵdefineComponent({
type: ComponentWithProviders,
selectors: [['component-with-providers']],
@ -1038,7 +1038,7 @@ describe('providers', () => {
class EmbeddedComponent {
constructor(private s: String) {}
static ngFactoryDef = () => new EmbeddedComponent(ɵɵdirectiveInject(String));
static ɵfac = () => new EmbeddedComponent(ɵɵdirectiveInject(String));
static ɵcmp = ɵɵdefineComponent({
type: EmbeddedComponent,
selectors: [['embedded-cmp']],
@ -1059,7 +1059,7 @@ describe('providers', () => {
class HostComponent {
constructor(public vcref: ViewContainerRef, public cfr: ComponentFactoryResolver) {}
static ngFactoryDef = () => hostComponent = new HostComponent(
static ɵfac = () => hostComponent = new HostComponent(
ɵɵdirectiveInject(ViewContainerRef as any), injectComponentFactoryResolver())
static ɵcmp = ɵɵdefineComponent({
@ -1085,7 +1085,7 @@ describe('providers', () => {
class AppComponent {
constructor() {}
static ngFactoryDef = () => new AppComponent();
static ɵfac = () => new AppComponent();
static ɵcmp = ɵɵdefineComponent({
type: AppComponent,
selectors: [['app-cmp']],
@ -1247,7 +1247,7 @@ describe('providers', () => {
class MyComponent {
constructor() {}
static ngFactoryDef = () => new MyComponent();
static ɵfac = () => new MyComponent();
static ɵcmp = ɵɵdefineComponent({
type: MyComponent,
selectors: [['my-cmp']],
@ -1274,7 +1274,7 @@ describe('providers', () => {
class AppComponent {
constructor() {}
static ngFactoryDef = () => new AppComponent();
static ɵfac = () => new AppComponent();
static ɵcmp = ɵɵdefineComponent({
type: AppComponent,
selectors: [['app-cmp']],
@ -1337,7 +1337,7 @@ describe('providers', () => {
class MyComponent {
constructor(foo: InjectableWithLifeCycleHooks) {}
static ngFactoryDef =
static ɵfac =
() => { return new MyComponent(ɵɵdirectiveInject(InjectableWithLifeCycleHooks)); }
static ɵcmp = ɵɵdefineComponent({
@ -1366,7 +1366,7 @@ describe('providers', () => {
class App {
public condition = true;
static ngFactoryDef = () => new App();
static ɵfac = () => new App();
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app-cmp']],
@ -1441,7 +1441,7 @@ function expectProvidersScenario(defs: {
}
class ViewChildComponent {
static ngFactoryDef = () => testComponentInjection(defs.viewChild, new ViewChildComponent());
static ɵfac = () => testComponentInjection(defs.viewChild, new ViewChildComponent());
static ɵcmp = ɵɵdefineComponent({
type: ViewChildComponent,
selectors: [['view-child']],
@ -1458,7 +1458,7 @@ function expectProvidersScenario(defs: {
}
class ViewChildDirective {
static ngFactoryDef = () => testDirectiveInjection(defs.viewChild, new ViewChildDirective());
static ɵfac = () => testDirectiveInjection(defs.viewChild, new ViewChildDirective());
static ɵdir = ɵɵdefineDirective({
type: ViewChildDirective,
selectors: [['view-child']],
@ -1467,7 +1467,7 @@ function expectProvidersScenario(defs: {
}
class ContentChildComponent {
static ngFactoryDef =
static ɵfac =
() => { return testComponentInjection(defs.contentChild, new ContentChildComponent()); }
static ɵcmp = ɵɵdefineComponent({
@ -1487,7 +1487,7 @@ function expectProvidersScenario(defs: {
}
class ContentChildDirective {
static ngFactoryDef =
static ɵfac =
() => { return testDirectiveInjection(defs.contentChild, new ContentChildDirective()); }
static ɵdir = ɵɵdefineDirective({
@ -1500,7 +1500,7 @@ function expectProvidersScenario(defs: {
class ParentComponent {
static ngFactoryDef = () => testComponentInjection(defs.parent, new ParentComponent());
static ɵfac = () => testComponentInjection(defs.parent, new ParentComponent());
static ɵcmp = ɵɵdefineComponent({
type: ParentComponent,
selectors: [['parent']],
@ -1518,7 +1518,7 @@ function expectProvidersScenario(defs: {
}
class ParentDirective {
static ngFactoryDef = () => testDirectiveInjection(defs.parent, new ParentDirective());
static ɵfac = () => testDirectiveInjection(defs.parent, new ParentDirective());
static ɵdir = ɵɵdefineDirective({
type: ParentDirective,
selectors: [['parent']],
@ -1527,7 +1527,7 @@ function expectProvidersScenario(defs: {
}
class ParentDirective2 {
static ngFactoryDef = () => testDirectiveInjection(defs.parent, new ParentDirective2());
static ɵfac = () => testDirectiveInjection(defs.parent, new ParentDirective2());
static ɵdir = ɵɵdefineDirective({
type: ParentDirective2,
selectors: [['parent']],
@ -1537,7 +1537,7 @@ function expectProvidersScenario(defs: {
class App {
static ngFactoryDef = () => testComponentInjection(defs.app, new App());
static ɵfac = () => testComponentInjection(defs.app, new App());
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app']],

View File

@ -19,7 +19,7 @@ describe('object literals', () => {
// TODO(issue/24571): remove '!'.
config !: {[key: string]: any};
static ngFactoryDef = function ObjectComp_Factory() { return objectComp = new ObjectComp(); };
static ɵfac = function ObjectComp_Factory() { return objectComp = new ObjectComp(); };
static ɵcmp = ɵɵdefineComponent({
type: ObjectComp,
selectors: [['object-comp']],

View File

@ -220,7 +220,7 @@ describe('query', () => {
class MyDirective {
constructor(public service: Service) {}
static ngFactoryDef = function MyDirective_Factory() {
static ɵfac = function MyDirective_Factory() {
return directive = new MyDirective(ɵɵdirectiveInject(Service));
};
static ɵdir = ɵɵdefineDirective({
@ -248,7 +248,7 @@ describe('query', () => {
service?: Service;
alias?: Alias;
static ngFactoryDef = function App_Factory() { return new App(); };
static ɵfac = function App_Factory() { return new App(); };
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app']],
@ -294,7 +294,7 @@ describe('query', () => {
class App {
service?: Service;
static ngFactoryDef = function App_Factory() { return new App(); };
static ɵfac = function App_Factory() { return new App(); };
static ɵcmp = ɵɵdefineComponent({
type: App,
selectors: [['app']],
@ -838,7 +838,7 @@ describe('query', () => {
let childInstance: Child;
class Child {
static ngFactoryDef = () => childInstance = new Child();
static ɵfac = () => childInstance = new Child();
static ɵcmp = ɵɵdefineComponent({
type: Child,
selectors: [['child']],
@ -1420,7 +1420,7 @@ describe('query', () => {
this.vcr.createEmbeddedView(this.temp);
}
static ngFactoryDef = () => new SomeDir(
static ɵfac = () => new SomeDir(
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any))
static ɵdir = ɵɵdefineDirective({
@ -1481,7 +1481,7 @@ describe('query', () => {
this.contentCheckedQuerySnapshot = this.foos ? this.foos.length : 0;
}
static ngFactoryDef = () => withContentInstance = new WithContentDirective();
static ɵfac = () => withContentInstance = new WithContentDirective();
static ɵdir = ɵɵdefineDirective({
type: WithContentDirective,
selectors: [['', 'with-content', '']],
@ -1679,7 +1679,7 @@ describe('query', () => {
it('should report results to appropriate queries where deep content queries are nested', () => {
class QueryDirective {
fooBars: any;
static ngFactoryDef = () => new QueryDirective();
static ɵfac = () => new QueryDirective();
static ɵdir = ɵɵdefineDirective({
type: QueryDirective,
selectors: [['', 'query', '']],
@ -1745,7 +1745,7 @@ describe('query', () => {
class QueryDirective {
fooBars: any;
static ngFactoryDef = () => new QueryDirective();
static ɵfac = () => new QueryDirective();
static ɵdir = ɵɵdefineDirective({
type: QueryDirective,
selectors: [['', 'query', '']],
@ -1802,7 +1802,7 @@ describe('query', () => {
class QueryDirective {
fooBars: any;
static ngFactoryDef = () => new QueryDirective();
static ɵfac = () => new QueryDirective();
static ɵdir = ɵɵdefineDirective({
type: QueryDirective,
selectors: [['', 'query', '']],
@ -1863,7 +1863,7 @@ describe('query', () => {
() => {
class ShallowQueryDirective {
foos: any;
static ngFactoryDef = () => new ShallowQueryDirective();
static ɵfac = () => new ShallowQueryDirective();
static ɵdir = ɵɵdefineDirective({
type: ShallowQueryDirective,
selectors: [['', 'shallow-query', '']],
@ -1884,7 +1884,7 @@ describe('query', () => {
class DeepQueryDirective {
foos: any;
static ngFactoryDef = () => new DeepQueryDirective();
static ɵfac = () => new DeepQueryDirective();
static ɵdir = ɵɵdefineDirective({
type: DeepQueryDirective,
selectors: [['', 'deep-query', '']],
@ -1946,7 +1946,7 @@ describe('query', () => {
class TextDirective {
value !: string;
static ngFactoryDef = () => new TextDirective();
static ɵfac = () => new TextDirective();
static ɵdir = ɵɵdefineDirective(
{type: TextDirective, selectors: [['', 'text', '']], inputs: {value: 'text'}});
}
@ -1958,7 +1958,7 @@ describe('query', () => {
// @ContentChildren(TextDirective)
texts !: QueryList<TextDirective>;
static ngFactoryDef = () => contentQueryDirective = new ContentQueryDirective();
static ɵfac = () => contentQueryDirective = new ContentQueryDirective();
static ɵcmp = ɵɵdefineDirective({
type: ContentQueryDirective,
selectors: [['', 'content-query', '']],
@ -2029,7 +2029,7 @@ describe('query', () => {
// @ViewChildren(TextDirective)
texts !: QueryList<TextDirective>;
static ngFactoryDef = () => new ViewQueryComponent();
static ɵfac = () => new ViewQueryComponent();
static ɵcmp = ɵɵdefineComponent({
type: ViewQueryComponent,
selectors: [['view-query']],

View File

@ -374,7 +374,7 @@ export function createComponent(
consts: TAttributes[] = []): ComponentType<any> {
return class Component {
value: any;
static ngFactoryDef = () => new Component;
static ɵfac = () => new Component;
static ɵcmp = ɵɵdefineComponent({
type: Component,
selectors: [[name]],
@ -394,7 +394,7 @@ export function createComponent(
export function createDirective(
name: string, {exportAs}: {exportAs?: string[]} = {}): DirectiveType<any> {
return class Directive {
static ngFactoryDef = () => new Directive();
static ɵfac = () => new Directive();
static ɵdir = ɵɵdefineDirective({
type: Directive,
selectors: [['', name, '']],

View File

@ -26,7 +26,7 @@ describe('renderer factory lifecycle', () => {
rendererFactory.end = () => logs.push('end');
class SomeComponent {
static ngFactoryDef = () => new SomeComponent;
static ɵfac = () => new SomeComponent;
static ɵcmp = ɵɵdefineComponent({
type: SomeComponent,
encapsulation: ViewEncapsulation.None,
@ -46,7 +46,7 @@ describe('renderer factory lifecycle', () => {
}
class SomeComponentWhichThrows {
static ngFactoryDef = () => new SomeComponentWhichThrows;
static ɵfac = () => new SomeComponentWhichThrows;
static ɵcmp = ɵɵdefineComponent({
type: SomeComponentWhichThrows,
encapsulation: ViewEncapsulation.None,
@ -150,7 +150,7 @@ describe('Renderer2 destruction hooks', () => {
it('should call renderer.destroy for each component destroyed', () => {
class SimpleComponent {
static ngFactoryDef = () => new SimpleComponent;
static ɵfac = () => new SimpleComponent;
static ɵcmp = ɵɵdefineComponent({
type: SimpleComponent,
encapsulation: ViewEncapsulation.None,

View File

@ -29,7 +29,7 @@ describe('ViewContainerRef', () => {
beforeEach(() => directiveInstance = null);
class DirectiveWithVCRef {
static ngFactoryDef = () => directiveInstance = new DirectiveWithVCRef(
static ɵfac = () => directiveInstance = new DirectiveWithVCRef(
ɵɵdirectiveInject(ViewContainerRef as any), injectComponentFactoryResolver())
static ɵdir = ɵɵdefineDirective({
@ -57,7 +57,7 @@ describe('ViewContainerRef', () => {
let directiveInstances: TestDirective[] = [];
class TestDirective {
static ngFactoryDef =
static ɵfac =
() => {
const instance = new TestDirective(
ɵɵdirectiveInject(ViewContainerRef as any),
@ -101,7 +101,7 @@ describe('ViewContainerRef', () => {
class TestComponent {
// TODO(issue/24571): remove '!'.
testDir !: TestDirective;
static ngFactoryDef = () => new TestComponent();
static ɵfac = () => new TestComponent();
static ɵcmp = ɵɵdefineComponent({
type: TestComponent,
encapsulation: ViewEncapsulation.None,
@ -137,7 +137,7 @@ describe('ViewContainerRef', () => {
let directiveInstance: TestDirective;
class TestDirective {
static ngFactoryDef = () => directiveInstance = new TestDirective(
static ɵfac = () => directiveInstance = new TestDirective(
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any))
static ɵdir =
@ -173,7 +173,7 @@ describe('ViewContainerRef', () => {
condition = false;
// TODO(issue/24571): remove '!'.
testDir !: TestDirective;
static ngFactoryDef = () => new TestComponent();
static ɵfac = () => new TestComponent();
static ɵcmp = ɵɵdefineComponent({
type: TestComponent,
encapsulation: ViewEncapsulation.None,
@ -241,7 +241,7 @@ describe('ViewContainerRef', () => {
class AppComp {
constructor(public vcr: ViewContainerRef, public cfr: ComponentFactoryResolver) {}
static ngFactoryDef =
static ɵfac =
() => {
return new AppComp(
ɵɵdirectiveInject(ViewContainerRef as any), injectComponentFactoryResolver());
@ -261,7 +261,7 @@ describe('ViewContainerRef', () => {
ngDoCheck() { this.doCheckCount++; }
static ngFactoryDef = () => dynamicComp = new DynamicComp();
static ɵfac = () => dynamicComp = new DynamicComp();
static ɵcmp = ɵɵdefineComponent({
type: DynamicComp,
@ -365,7 +365,7 @@ describe('ViewContainerRef', () => {
@Component({selector: 'app', template: ''})
class AppCmpt {
static ngFactoryDef = () =>
static ɵfac = () =>
new AppCmpt(ɵɵdirectiveInject(ViewContainerRef as any), injectComponentFactoryResolver())
static ɵcmp = ɵɵdefineComponent({
@ -435,7 +435,7 @@ describe('ViewContainerRef', () => {
// @ViewChildren('foo')
foo !: QueryList<any>;
static ngFactoryDef = () => dynamicComp = new DynamicCompWithViewQueries();
static ɵfac = () => dynamicComp = new DynamicCompWithViewQueries();
static ɵcmp = ɵɵdefineComponent({
type: DynamicCompWithViewQueries,
selectors: [['dynamic-cmpt-with-view-queries']],
@ -482,7 +482,7 @@ describe('ViewContainerRef', () => {
// We want the ViewRef, so we rely on the knowledge that `ViewRef` is actually given
// when injecting `ChangeDetectorRef`.
static ngFactoryDef = () =>
static ɵfac = () =>
new CompWithListenerThatDestroysItself(ɵɵdirectiveInject(ChangeDetectorRef as any))
static ɵcmp = ɵɵdefineComponent({

View File

@ -505,7 +505,7 @@ describe('TestBed', () => {
*/
const getAOTCompiledComponent = () => {
class ComponentClass {
static ngFactoryDef = () => new ComponentClass();
static ɵfac = () => new ComponentClass();
static ɵcmp = defineComponent({
type: ComponentClass,
selectors: [['comp']],