refactor(core): rename ngDirectiveDef to ɵdir (#33110)
Directive 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 ngDirectiveDef to dir. 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" (ngFactoryDef, 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 #33110
This commit is contained in:
parent
d8249d1230
commit
1a67d70bf8
@ -54,16 +54,16 @@ export const ngClassFactoryDef = ngClassFactoryDef__PRE_R3__;
|
|||||||
* While this is a base class that NgClass extends from, the
|
* While this is a base class that NgClass extends from, the
|
||||||
* class itself acts as a container for non-VE code to setup
|
* class itself acts as a container for non-VE code to setup
|
||||||
* a link to the `[class]` host binding (via the static
|
* a link to the `[class]` host binding (via the static
|
||||||
* `ngDirectiveDef` property on the class).
|
* `ɵdir` property on the class).
|
||||||
*
|
*
|
||||||
* Note that the `ngDirectiveDef` property's code is switched
|
* Note that the `ɵdir` property's code is switched
|
||||||
* depending if VE is present or not (this allows for the
|
* depending if VE is present or not (this allows for the
|
||||||
* binding code to be set only for newer versions of Angular).
|
* binding code to be set only for newer versions of Angular).
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export class NgClassBase {
|
export class NgClassBase {
|
||||||
static ngDirectiveDef: any = ngClassDirectiveDef;
|
static ɵdir: any = ngClassDirectiveDef;
|
||||||
static ngFactoryDef: any = ngClassFactoryDef;
|
static ngFactoryDef: any = ngClassFactoryDef;
|
||||||
|
|
||||||
constructor(protected _delegate: NgClassImpl) {}
|
constructor(protected _delegate: NgClassImpl) {}
|
||||||
|
@ -54,16 +54,16 @@ export const ngStyleFactoryDef = ngStyleDirectiveDef__PRE_R3__;
|
|||||||
* While this is a base class that NgStyle extends from, the
|
* While this is a base class that NgStyle extends from, the
|
||||||
* class itself acts as a container for non-VE code to setup
|
* class itself acts as a container for non-VE code to setup
|
||||||
* a link to the `[style]` host binding (via the static
|
* a link to the `[style]` host binding (via the static
|
||||||
* `ngDirectiveDef` property on the class).
|
* `ɵdir` property on the class).
|
||||||
*
|
*
|
||||||
* Note that the `ngDirectiveDef` property's code is switched
|
* Note that the `ɵdir` property's code is switched
|
||||||
* depending if VE is present or not (this allows for the
|
* depending if VE is present or not (this allows for the
|
||||||
* binding code to be set only for newer versions of Angular).
|
* binding code to be set only for newer versions of Angular).
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export class NgStyleBase {
|
export class NgStyleBase {
|
||||||
static ngDirectiveDef: any = ngStyleDirectiveDef;
|
static ɵdir: any = ngStyleDirectiveDef;
|
||||||
static ngFactory: any = ngStyleFactoryDef;
|
static ngFactory: any = ngStyleFactoryDef;
|
||||||
|
|
||||||
constructor(protected _delegate: NgStyleImpl) {}
|
constructor(protected _delegate: NgStyleImpl) {}
|
||||||
|
@ -28,8 +28,8 @@ import {createDirectiveDecorator, hasConstructor, hasDirectiveDecorator, isClass
|
|||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* When compiling `DerivedDir` which extends the undecorated `BasePlain` class, the compiler needs
|
* When compiling `DerivedDir` which extends the undecorated `BasePlain` class, the compiler needs
|
||||||
* to generate an `ngDirectiveDef` for `DerivedDir`. In particular, it needs to generate a factory
|
* to generate a directive def (`ɵdir`) for `DerivedDir`. In particular, it needs to generate a
|
||||||
* function that creates instances of `DerivedDir`.
|
* factory function that creates instances of `DerivedDir`.
|
||||||
*
|
*
|
||||||
* As `DerivedDir` has no constructor, the factory function for `DerivedDir` must delegate to the
|
* As `DerivedDir` has no constructor, the factory function for `DerivedDir` must delegate to the
|
||||||
* factory function for `BasePlain`. But for this to work, `BasePlain` must have a factory function,
|
* factory function for `BasePlain`. But for this to work, `BasePlain` must have a factory function,
|
||||||
|
@ -119,7 +119,7 @@ runInEachFileSystem(() => {
|
|||||||
const typingsFile = result.find(f => f.path === _('/typings/file.d.ts')) !;
|
const typingsFile = result.find(f => f.path === _('/typings/file.d.ts')) !;
|
||||||
expect(typingsFile.contents)
|
expect(typingsFile.contents)
|
||||||
.toContain(
|
.toContain(
|
||||||
'foo(x: number): number;\n static ngFactoryDef: ɵngcc0.ɵɵFactoryDef<A>;\n static ngDirectiveDef: ɵngcc0.ɵɵDirectiveDefWithMeta');
|
'foo(x: number): number;\n static ngFactoryDef: ɵngcc0.ɵɵFactoryDef<A>;\n static ɵdir: ɵngcc0.ɵɵDirectiveDefWithMeta');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render imports into typings files', () => {
|
it('should render imports into typings files', () => {
|
||||||
|
@ -230,7 +230,7 @@ A.ɵcmp = ɵngcc0.ɵɵdefineComponent({ type: A, selectors: [["a"]], decls: 1, v
|
|||||||
|
|
||||||
expect(addDefinitionsSpy.calls.first().args[2])
|
expect(addDefinitionsSpy.calls.first().args[2])
|
||||||
.toEqual(`A.ngFactoryDef = function A_Factory(t) { return new (t || A)(); };
|
.toEqual(`A.ngFactoryDef = function A_Factory(t) { return new (t || A)(); };
|
||||||
A.ngDirectiveDef = ɵngcc0.ɵɵdefineDirective({ type: A, selectors: [["", "a", ""]] });
|
A.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: A, selectors: [["", "a", ""]] });
|
||||||
/*@__PURE__*/ ɵngcc0.ɵsetClassMetadata(A, [{
|
/*@__PURE__*/ ɵngcc0.ɵsetClassMetadata(A, [{
|
||||||
type: Directive,
|
type: Directive,
|
||||||
args: [{ selector: '[a]' }]
|
args: [{ selector: '[a]' }]
|
||||||
|
@ -100,7 +100,7 @@ export class DirectiveDecoratorHandler implements
|
|||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
factoryRes, {
|
factoryRes, {
|
||||||
name: 'ngDirectiveDef',
|
name: 'ɵdir',
|
||||||
initializer: res.expression,
|
initializer: res.expression,
|
||||||
statements: [],
|
statements: [],
|
||||||
type: res.type,
|
type: res.type,
|
||||||
|
@ -69,7 +69,7 @@ export class DtsMetadataReader implements MetadataReader {
|
|||||||
getDirectiveMetadata(ref: Reference<ClassDeclaration>): DirectiveMeta|null {
|
getDirectiveMetadata(ref: Reference<ClassDeclaration>): DirectiveMeta|null {
|
||||||
const clazz = ref.node;
|
const clazz = ref.node;
|
||||||
const def = this.reflector.getMembersOfClass(clazz).find(
|
const def = this.reflector.getMembersOfClass(clazz).find(
|
||||||
field => field.isStatic && (field.name === 'ɵcmp' || field.name === 'ngDirectiveDef'));
|
field => field.isStatic && (field.name === 'ɵcmp' || field.name === 'ɵdir'));
|
||||||
if (def === undefined) {
|
if (def === undefined) {
|
||||||
// No definition could be found.
|
// No definition could be found.
|
||||||
return null;
|
return null;
|
||||||
|
@ -85,7 +85,7 @@ runInEachFileSystem(() => {
|
|||||||
const {resolver, refs} = makeTestEnv({
|
const {resolver, refs} = makeTestEnv({
|
||||||
'test': `
|
'test': `
|
||||||
export declare class Dir {
|
export declare class Dir {
|
||||||
static ngDirectiveDef: DirectiveMeta<Dir, '[dir]', ['exportAs'], {'input': 'input2'},
|
static ɵdir: DirectiveMeta<Dir, '[dir]', ['exportAs'], {'input': 'input2'},
|
||||||
{'output': 'output2'}, ['query']>;
|
{'output': 'output2'}, ['query']>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ runInEachFileSystem(() => {
|
|||||||
const {resolver, refs} = makeTestEnv({
|
const {resolver, refs} = makeTestEnv({
|
||||||
'test': `
|
'test': `
|
||||||
export declare class Dir {
|
export declare class Dir {
|
||||||
static ngDirectiveDef: DirectiveMeta<Dir, '[dir]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<Dir, '[dir]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ModuleA {
|
export declare class ModuleA {
|
||||||
@ -124,7 +124,7 @@ runInEachFileSystem(() => {
|
|||||||
const {resolver, refs} = makeTestEnv({
|
const {resolver, refs} = makeTestEnv({
|
||||||
'declaration': `
|
'declaration': `
|
||||||
export declare class Dir {
|
export declare class Dir {
|
||||||
static ngDirectiveDef: DirectiveMeta<Dir, '[dir]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<Dir, '[dir]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ModuleA {
|
export declare class ModuleA {
|
||||||
@ -152,7 +152,7 @@ runInEachFileSystem(() => {
|
|||||||
{
|
{
|
||||||
'deep': `
|
'deep': `
|
||||||
export declare class DeepDir {
|
export declare class DeepDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<DeepDir, '[deep]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<DeepDir, '[deep]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class DeepModule {
|
export declare class DeepModule {
|
||||||
@ -163,7 +163,7 @@ runInEachFileSystem(() => {
|
|||||||
import * as deep from 'deep';
|
import * as deep from 'deep';
|
||||||
|
|
||||||
export declare class MiddleDir {
|
export declare class MiddleDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<MiddleDir, '[middle]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<MiddleDir, '[middle]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class MiddleModule {
|
export declare class MiddleModule {
|
||||||
@ -174,7 +174,7 @@ runInEachFileSystem(() => {
|
|||||||
import * as middle from 'middle';
|
import * as middle from 'middle';
|
||||||
|
|
||||||
export declare class ShallowDir {
|
export declare class ShallowDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<ShallowDir, '[middle]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<ShallowDir, '[middle]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ShallowModule {
|
export declare class ShallowModule {
|
||||||
@ -202,7 +202,7 @@ runInEachFileSystem(() => {
|
|||||||
{
|
{
|
||||||
'deep': `
|
'deep': `
|
||||||
export declare class DeepDir {
|
export declare class DeepDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<DeepDir, '[deep]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<DeepDir, '[deep]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class DeepModule {
|
export declare class DeepModule {
|
||||||
@ -213,7 +213,7 @@ runInEachFileSystem(() => {
|
|||||||
import * as deep from 'deep';
|
import * as deep from 'deep';
|
||||||
|
|
||||||
export declare class MiddleDir {
|
export declare class MiddleDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<MiddleDir, '[middle]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<MiddleDir, '[middle]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class MiddleModule {
|
export declare class MiddleModule {
|
||||||
@ -224,7 +224,7 @@ runInEachFileSystem(() => {
|
|||||||
import * as middle from 'middle';
|
import * as middle from 'middle';
|
||||||
|
|
||||||
export declare class ShallowDir {
|
export declare class ShallowDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<ShallowDir, '[middle]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<ShallowDir, '[middle]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ShallowModule {
|
export declare class ShallowModule {
|
||||||
@ -253,7 +253,7 @@ runInEachFileSystem(() => {
|
|||||||
{
|
{
|
||||||
'module': `
|
'module': `
|
||||||
export declare class DeepDir {
|
export declare class DeepDir {
|
||||||
static ngDirectiveDef: DirectiveMeta<DeepDir, '[deep]', never, never, never, never>;
|
static ɵdir: DirectiveMeta<DeepDir, '[deep]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class DeepModule {
|
export declare class DeepModule {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
const R3_DEF_NAME_PATTERN = [
|
const R3_DEF_NAME_PATTERN = [
|
||||||
'ngBaseDef',
|
'ngBaseDef',
|
||||||
'ɵcmp',
|
'ɵcmp',
|
||||||
'ngDirectiveDef',
|
'ɵdir',
|
||||||
'ngInjectableDef',
|
'ngInjectableDef',
|
||||||
'ngInjectorDef',
|
'ngInjectorDef',
|
||||||
'ngModuleDef',
|
'ngModuleDef',
|
||||||
|
@ -583,7 +583,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
// SomeDirective definition should be:
|
// SomeDirective definition should be:
|
||||||
const SomeDirectiveDefinition = `
|
const SomeDirectiveDefinition = `
|
||||||
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
SomeDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: SomeDirective,
|
type: SomeDirective,
|
||||||
selectors: [["", "some-directive", ""]]
|
selectors: [["", "some-directive", ""]]
|
||||||
});
|
});
|
||||||
@ -620,7 +620,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
|
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
|
||||||
expectEmit(source, ChildComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
|
expectEmit(source, ChildComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
|
||||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
|
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ɵdir');
|
||||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
||||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponentDefinition.ɵcmp');
|
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponentDefinition.ɵcmp');
|
||||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ngFactoryDef');
|
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ngFactoryDef');
|
||||||
@ -646,7 +646,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
// SomeDirective definition should be:
|
// SomeDirective definition should be:
|
||||||
const SomeDirectiveDefinition = `
|
const SomeDirectiveDefinition = `
|
||||||
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
SomeDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: SomeDirective,
|
type: SomeDirective,
|
||||||
selectors: [["div", "some-directive", "", 8, "foo", 3, "title", "", 9, "baz"]]
|
selectors: [["div", "some-directive", "", 8, "foo", 3, "title", "", 9, "baz"]]
|
||||||
});
|
});
|
||||||
@ -657,7 +657,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
// OtherDirective definition should be:
|
// OtherDirective definition should be:
|
||||||
const OtherDirectiveDefinition = `
|
const OtherDirectiveDefinition = `
|
||||||
OtherDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
OtherDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: OtherDirective,
|
type: OtherDirective,
|
||||||
selectors: [["", 5, "span", "title", "", 9, "baz"]]
|
selectors: [["", 5, "span", "title", "", 9, "baz"]]
|
||||||
});
|
});
|
||||||
@ -669,9 +669,9 @@ describe('compiler compliance', () => {
|
|||||||
const result = compile(files, angularFiles);
|
const result = compile(files, angularFiles);
|
||||||
const source = result.source;
|
const source = result.source;
|
||||||
|
|
||||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
|
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ɵdir');
|
||||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
||||||
expectEmit(source, OtherDirectiveDefinition, 'Incorrect OtherDirective.ngDirectiveDef');
|
expectEmit(source, OtherDirectiveDefinition, 'Incorrect OtherDirective.ɵdir');
|
||||||
expectEmit(source, OtherDirectiveFactory, 'Incorrect OtherDirective.ngFactoryDef');
|
expectEmit(source, OtherDirectiveFactory, 'Incorrect OtherDirective.ngFactoryDef');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -789,7 +789,7 @@ describe('compiler compliance', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const IfDirectiveDefinition = `
|
const IfDirectiveDefinition = `
|
||||||
IfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
IfDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: IfDirective,
|
type: IfDirective,
|
||||||
selectors: [["", "if", ""]]
|
selectors: [["", "if", ""]]
|
||||||
});`;
|
});`;
|
||||||
@ -835,7 +835,7 @@ describe('compiler compliance', () => {
|
|||||||
const result = compile(files, angularFiles);
|
const result = compile(files, angularFiles);
|
||||||
const source = result.source;
|
const source = result.source;
|
||||||
|
|
||||||
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ngDirectiveDef');
|
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ɵdir');
|
||||||
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ngFactoryDef');
|
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ngFactoryDef');
|
||||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
|
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
|
||||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
|
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
|
||||||
@ -2595,7 +2595,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
// TODO(benlesh): Enforce this when the directives are specified
|
// TODO(benlesh): Enforce this when the directives are specified
|
||||||
const ForDirectiveDefinition = `
|
const ForDirectiveDefinition = `
|
||||||
ForOfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
ForOfDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: ForOfDirective,
|
type: ForOfDirective,
|
||||||
selectors: [["", "forOf", ""]],
|
selectors: [["", "forOf", ""]],
|
||||||
features: [$r3$.ɵɵNgOnChangesFeature()],
|
features: [$r3$.ɵɵNgOnChangesFeature()],
|
||||||
@ -2676,7 +2676,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
// TODO(chuckj): Enforce this when the directives are specified
|
// TODO(chuckj): Enforce this when the directives are specified
|
||||||
const ForDirectiveDefinition = `
|
const ForDirectiveDefinition = `
|
||||||
ForOfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
ForOfDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: ForOfDirective,
|
type: ForOfDirective,
|
||||||
selectors: [["", "forOf", ""]],
|
selectors: [["", "forOf", ""]],
|
||||||
features: [$r3$.ɵɵNgOnChangesFeature()],
|
features: [$r3$.ɵɵNgOnChangesFeature()],
|
||||||
@ -2926,7 +2926,7 @@ describe('compiler compliance', () => {
|
|||||||
|
|
||||||
// SomeDirective definition should be:
|
// SomeDirective definition should be:
|
||||||
const SomeDirectiveDefinition = `
|
const SomeDirectiveDefinition = `
|
||||||
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
SomeDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: SomeDirective,
|
type: SomeDirective,
|
||||||
selectors: [["", "some-directive", ""]],
|
selectors: [["", "some-directive", ""]],
|
||||||
exportAs: ["someDir", "otherDir"]
|
exportAs: ["someDir", "otherDir"]
|
||||||
@ -2936,7 +2936,7 @@ describe('compiler compliance', () => {
|
|||||||
const result = compile(files, angularFiles);
|
const result = compile(files, angularFiles);
|
||||||
const source = result.source;
|
const source = result.source;
|
||||||
|
|
||||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
|
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ɵdir');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw for empty property bindings on ng-template', () => {
|
it('should not throw for empty property bindings on ng-template', () => {
|
||||||
|
@ -668,7 +668,7 @@ describe('compiler compliance: bindings', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const HostBindingDirDeclaration = `
|
const HostBindingDirDeclaration = `
|
||||||
HostBindingDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
HostBindingDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: HostBindingDir,
|
type: HostBindingDir,
|
||||||
selectors: [["", "hostBindingDir", ""]],
|
selectors: [["", "hostBindingDir", ""]],
|
||||||
hostBindings: function HostBindingDir_HostBindings(rf, ctx, elIndex) {
|
hostBindings: function HostBindingDir_HostBindings(rf, ctx, elIndex) {
|
||||||
@ -761,7 +761,7 @@ describe('compiler compliance: bindings', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const HostAttributeDirDeclaration = `
|
const HostAttributeDirDeclaration = `
|
||||||
HostAttributeDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
HostAttributeDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: HostAttributeDir,
|
type: HostAttributeDir,
|
||||||
selectors: [["", "hostAttributeDir", ""]],
|
selectors: [["", "hostAttributeDir", ""]],
|
||||||
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
||||||
@ -805,7 +805,7 @@ describe('compiler compliance: bindings', () => {
|
|||||||
const HostAttributeDirDeclaration = `
|
const HostAttributeDirDeclaration = `
|
||||||
const $c0$ = ["aria-label", "label"];
|
const $c0$ = ["aria-label", "label"];
|
||||||
…
|
…
|
||||||
HostAttributeDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
HostAttributeDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: HostAttributeDir,
|
type: HostAttributeDir,
|
||||||
selectors: [["", "hostAttributeDir", ""]],
|
selectors: [["", "hostAttributeDir", ""]],
|
||||||
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
||||||
@ -873,7 +873,7 @@ describe('compiler compliance: bindings', () => {
|
|||||||
…
|
…
|
||||||
}
|
}
|
||||||
…
|
…
|
||||||
HostAttributeDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
HostAttributeDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
type: HostAttributeDir,
|
type: HostAttributeDir,
|
||||||
selectors: [["", "hostAttributeDir", ""]],
|
selectors: [["", "hostAttributeDir", ""]],
|
||||||
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
||||||
|
@ -66,7 +66,7 @@ describe('compiler compliance: listen()', () => {
|
|||||||
});`;
|
});`;
|
||||||
|
|
||||||
const directiveDef = `
|
const directiveDef = `
|
||||||
MyDirective.ngDirectiveDef = IDENT.ɵɵdefineDirective({
|
MyDirective.ɵdir = IDENT.ɵɵdefineDirective({
|
||||||
…
|
…
|
||||||
inputs:{
|
inputs:{
|
||||||
directiveInput: "directiveInput",
|
directiveInput: "directiveInput",
|
||||||
|
@ -332,7 +332,7 @@ describe('compiler compliance: styling', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const template = `
|
const template = `
|
||||||
MyAnimDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
MyAnimDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||||
…
|
…
|
||||||
hostBindings: function MyAnimDir_HostBindings(rf, ctx, elIndex) {
|
hostBindings: function MyAnimDir_HostBindings(rf, ctx, elIndex) {
|
||||||
if (rf & 1) {
|
if (rf & 1) {
|
||||||
|
@ -373,7 +373,7 @@ runInEachFileSystem(os => {
|
|||||||
const jsContents = env.getContents('test.js');
|
const jsContents = env.getContents('test.js');
|
||||||
expect(jsContents).toContain('TestBase.ngBaseDef = i0.ɵɵdefineBase');
|
expect(jsContents).toContain('TestBase.ngBaseDef = i0.ɵɵdefineBase');
|
||||||
expect(jsContents).toContain('TestComponent.ɵcmp = i0.ɵɵdefineComponent');
|
expect(jsContents).toContain('TestComponent.ɵcmp = i0.ɵɵdefineComponent');
|
||||||
expect(jsContents).toContain('TestDirective.ngDirectiveDef = i0.ɵɵdefineDirective');
|
expect(jsContents).toContain('TestDirective.ɵdir = i0.ɵɵdefineDirective');
|
||||||
expect(jsContents).toContain('TestPipe.ngPipeDef = i0.ɵɵdefinePipe');
|
expect(jsContents).toContain('TestPipe.ngPipeDef = i0.ɵɵdefinePipe');
|
||||||
expect(jsContents).toContain('TestInjectable.ngInjectableDef = i0.ɵɵdefineInjectable');
|
expect(jsContents).toContain('TestInjectable.ngInjectableDef = i0.ɵɵdefineInjectable');
|
||||||
expect(jsContents).toContain('MyModule.ngModuleDef = i0.ɵɵdefineNgModule');
|
expect(jsContents).toContain('MyModule.ngModuleDef = i0.ɵɵdefineNgModule');
|
||||||
@ -1180,7 +1180,7 @@ runInEachFileSystem(os => {
|
|||||||
|
|
||||||
// Validate that each class has the primary definition.
|
// Validate that each class has the primary definition.
|
||||||
expect(jsContents).toContain('TestCmp.ɵcmp =');
|
expect(jsContents).toContain('TestCmp.ɵcmp =');
|
||||||
expect(jsContents).toContain('TestDir.ngDirectiveDef =');
|
expect(jsContents).toContain('TestDir.ɵdir =');
|
||||||
expect(jsContents).toContain('TestPipe.ngPipeDef =');
|
expect(jsContents).toContain('TestPipe.ngPipeDef =');
|
||||||
expect(jsContents).toContain('TestNgModule.ngModuleDef =');
|
expect(jsContents).toContain('TestNgModule.ngModuleDef =');
|
||||||
|
|
||||||
@ -2946,7 +2946,7 @@ runInEachFileSystem(os => {
|
|||||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||||
|
|
||||||
export declare class ExternalDir {
|
export declare class ExternalDir {
|
||||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ExternalModule {
|
export declare class ExternalModule {
|
||||||
@ -2990,7 +2990,7 @@ runInEachFileSystem(os => {
|
|||||||
env.write('node_modules/external/internal.d.ts', `
|
env.write('node_modules/external/internal.d.ts', `
|
||||||
|
|
||||||
export declare class InternalDir {
|
export declare class InternalDir {
|
||||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<InternalDir, '[test]', never, never, never, never>;
|
static ɵdir: ɵɵDirectiveDefWithMeta<InternalDir, '[test]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
env.write('test.ts', `
|
env.write('test.ts', `
|
||||||
@ -3233,7 +3233,7 @@ runInEachFileSystem(os => {
|
|||||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||||
|
|
||||||
export declare class ExternalDir {
|
export declare class ExternalDir {
|
||||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ExternalModule {
|
export declare class ExternalModule {
|
||||||
@ -4179,7 +4179,7 @@ export const Foo = Foo__PRE_R3__;
|
|||||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||||
|
|
||||||
export declare class ExternalDir {
|
export declare class ExternalDir {
|
||||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class AlphaModule {
|
export declare class AlphaModule {
|
||||||
@ -4230,7 +4230,7 @@ export const Foo = Foo__PRE_R3__;
|
|||||||
import {LibModule} from './lib';
|
import {LibModule} from './lib';
|
||||||
|
|
||||||
export declare class ExternalDir {
|
export declare class ExternalDir {
|
||||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class ExternalModule {
|
export declare class ExternalModule {
|
||||||
@ -4241,7 +4241,7 @@ export const Foo = Foo__PRE_R3__;
|
|||||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||||
|
|
||||||
export declare class LibDir {
|
export declare class LibDir {
|
||||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<LibDir, '[lib]', never, never, never, never>;
|
static ɵdir: ɵɵDirectiveDefWithMeta<LibDir, '[lib]', never, never, never, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class LibModule {
|
export declare class LibModule {
|
||||||
|
@ -46,13 +46,13 @@ export declare class IndexPipe {
|
|||||||
export declare class NgForOf<T> {
|
export declare class NgForOf<T> {
|
||||||
ngForOf: T[];
|
ngForOf: T[];
|
||||||
static ngTemplateContextGuard<T>(dir: NgForOf<T>, ctx: any): ctx is NgForOfContext<T>;
|
static ngTemplateContextGuard<T>(dir: NgForOf<T>, ctx: any): ctx is NgForOfContext<T>;
|
||||||
static ngDirectiveDef: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngFor][ngForOf]', never, {'ngForOf': 'ngForOf'}, {}, never>;
|
static ɵdir: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngFor][ngForOf]', never, {'ngForOf': 'ngForOf'}, {}, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class NgIf {
|
export declare class NgIf {
|
||||||
ngIf: any;
|
ngIf: any;
|
||||||
static ngTemplateGuard_ngIf: 'binding';
|
static ngTemplateGuard_ngIf: 'binding';
|
||||||
static ngDirectiveDef: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngIf]', never, {'ngIf': 'ngIf'}, {}, never>;
|
static ɵdir: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngIf]', never, {'ngIf': 'ngIf'}, {}, never>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class CommonModule {
|
export declare class CommonModule {
|
||||||
|
@ -171,7 +171,7 @@ There are also a list of helper decorators that make the `@Component` and `@Dire
|
|||||||
|
|
||||||
Each of the class decorators can be thought of as class transformers that take the declared class and transform it, possibly using information from the helper decorators, to produce an Angular class. The JIT compiler performs this transformation at runtime. The AoT compiler performs this transformation at compile time.
|
Each of the class decorators can be thought of as class transformers that take the declared class and transform it, possibly using information from the helper decorators, to produce an Angular class. The JIT compiler performs this transformation at runtime. The AoT compiler performs this transformation at compile time.
|
||||||
|
|
||||||
Each of the class decorators' class transformer creates a corresponding static member on the class that describes to the runtime how to use the class. For example, the `@Component` decorator creates a `ɵcmp` static member, `@Directive` create an `ngDirectiveDef`, etc. Internally, these class transformers are called a "Compiler". Most of the compilers are straight forward translations of the metadata specified in the decorator to the information provided in the corresponding definition and, therefore, do not require anything outside the source file to perform the conversion. However, the component, during production builds and for type checking a template require the module scope of the component which requires information from other files in the program.
|
Each of the class decorators' class transformer creates a corresponding static member on the class that describes to the runtime how to use the class. For example, the `@Component` decorator creates a `ɵcmp` static member, `@Directive` create a `ɵdir`, etc. Internally, these class transformers are called a "Compiler". Most of the compilers are straight forward translations of the metadata specified in the decorator to the information provided in the corresponding definition and, therefore, do not require anything outside the source file to perform the conversion. However, the component, during production builds and for type checking a template require the module scope of the component which requires information from other files in the program.
|
||||||
|
|
||||||
#### Compiler design
|
#### Compiler design
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ The mental model of Ivy is that the decorator is the compiler. That is
|
|||||||
the decorator can be thought of as parameters to a class transformer that
|
the decorator can be thought of as parameters to a class transformer that
|
||||||
transforms the class by generating definitions based on the decorator
|
transforms the class by generating definitions based on the decorator
|
||||||
parameters. An `@Component` decorator transforms the class by adding
|
parameters. An `@Component` decorator transforms the class by adding
|
||||||
a `ɵcmp` static property, `@Directive` adds `ngDirectiveDef`,
|
a `ɵcmp` static property, `@Directive` adds `ɵdir`,
|
||||||
`@Pipe` adds `ngPipeDef`, etc. In most cases values supplied to the
|
`@Pipe` adds `ngPipeDef`, etc. In most cases values supplied to the
|
||||||
decorator is sufficient to generate the definition. However, in the case of
|
decorator is sufficient to generate the definition. However, in the case of
|
||||||
interpreting the template, the compiler needs to know the selector defined for
|
interpreting the template, the compiler needs to know the selector defined for
|
||||||
@ -67,15 +67,15 @@ class:
|
|||||||
| `type` | implicit |
|
| `type` | implicit |
|
||||||
| `isComponent` | `ɵcmp` |
|
| `isComponent` | `ɵcmp` |
|
||||||
| `selector` | `ngModuleScope` |
|
| `selector` | `ngModuleScope` |
|
||||||
| `exportAs` | `ngDirectiveDef` |
|
| `exportAs` | `ɵdir` |
|
||||||
| `inputs` | `ngDirectiveDef` |
|
| `inputs` | `ɵdir` |
|
||||||
| `outputs` | `ngDirectiveDef` |
|
| `outputs` | `ɵdir` |
|
||||||
| `hostListeners` | `ngDirectiveDef` |
|
| `hostListeners` | `ɵdir` |
|
||||||
| `hostProperties` | `ngDirectiveDef` |
|
| `hostProperties` | `ɵdir` |
|
||||||
| `hostAttributes` | `ngDirectiveDef` |
|
| `hostAttributes` | `ɵdir` |
|
||||||
| `providers` | `ngInjectorDef` |
|
| `providers` | `ngInjectorDef` |
|
||||||
| `viewProviders` | `ɵcmp` |
|
| `viewProviders` | `ɵcmp` |
|
||||||
| `queries` | `ngDirectiveDef` |
|
| `queries` | `ɵdir` |
|
||||||
| `guards` | not used |
|
| `guards` | not used |
|
||||||
| `viewQueries` | `ɵcmp` |
|
| `viewQueries` | `ɵcmp` |
|
||||||
| `entryComponents` | not used |
|
| `entryComponents` | not used |
|
||||||
@ -86,8 +86,8 @@ class:
|
|||||||
| `componentFactory` | not used |
|
| `componentFactory` | not used |
|
||||||
|
|
||||||
Only one definition is generated per class. All components are directives so a
|
Only one definition is generated per class. All components are directives so a
|
||||||
`ɵcmp` contains all the `ngDirectiveDef` information. All directives
|
`ɵcmp` contains all the `ɵdir` information. All directives
|
||||||
are injectable so `ɵcmp` and `ngDirectiveDef` contain `ngInjectableDef`
|
are injectable so `ɵcmp` and `ɵdir` contain `ngInjectableDef`
|
||||||
information.
|
information.
|
||||||
|
|
||||||
For `CompilePipeSummary` the table looks like:
|
For `CompilePipeSummary` the table looks like:
|
||||||
@ -193,7 +193,7 @@ manually.
|
|||||||
The metadata for a directive is transformed by:
|
The metadata for a directive is transformed by:
|
||||||
|
|
||||||
1. Removing the `@Directive` directive.
|
1. Removing the `@Directive` directive.
|
||||||
2. Add `"ngDirectiveDef": {}` static field.
|
2. Add `"ɵdir": {}` static field.
|
||||||
3. Add `"ngSelector": <selector-value>` static field.
|
3. Add `"ngSelector": <selector-value>` static field.
|
||||||
|
|
||||||
##### example
|
##### example
|
||||||
@ -213,7 +213,7 @@ export class MyDirective {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.dirId = 'some id';
|
this.dirId = 'some id';
|
||||||
}
|
}
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({...});
|
static ɵdir = ɵɵdefineDirective({...});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ export class MyDirective {
|
|||||||
"MyDirective": {
|
"MyDirective": {
|
||||||
"__symbolic": "class",
|
"__symbolic": "class",
|
||||||
"statics": {
|
"statics": {
|
||||||
"ngDirectiveDef": {},
|
"ɵdir": {},
|
||||||
"ngSelector": "[my-dir]"
|
"ngSelector": "[my-dir]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ export class ConstantPool {
|
|||||||
case DefinitionKind.Component:
|
case DefinitionKind.Component:
|
||||||
return 'ɵcmp';
|
return 'ɵcmp';
|
||||||
case DefinitionKind.Directive:
|
case DefinitionKind.Directive:
|
||||||
return 'ngDirectiveDef';
|
return 'ɵdir';
|
||||||
case DefinitionKind.Injector:
|
case DefinitionKind.Injector:
|
||||||
return 'ngInjectorDef';
|
return 'ngInjectorDef';
|
||||||
case DefinitionKind.Pipe:
|
case DefinitionKind.Pipe:
|
||||||
|
@ -222,7 +222,7 @@ export {
|
|||||||
export {
|
export {
|
||||||
NG_ELEMENT_ID as ɵNG_ELEMENT_ID,
|
NG_ELEMENT_ID as ɵNG_ELEMENT_ID,
|
||||||
NG_COMP_DEF as ɵNG_COMP_DEF,
|
NG_COMP_DEF as ɵNG_COMP_DEF,
|
||||||
NG_DIRECTIVE_DEF as ɵNG_DIRECTIVE_DEF,
|
NG_DIR_DEF as ɵNG_DIR_DEF,
|
||||||
NG_PIPE_DEF as ɵNG_PIPE_DEF,
|
NG_PIPE_DEF as ɵNG_PIPE_DEF,
|
||||||
NG_MODULE_DEF as ɵNG_MODULE_DEF,
|
NG_MODULE_DEF as ɵNG_MODULE_DEF,
|
||||||
NG_BASE_DEF as ɵNG_BASE_DEF
|
NG_BASE_DEF as ɵNG_BASE_DEF
|
||||||
|
@ -13,7 +13,7 @@ Here is an abbreviated example of breakage of tree-shake-ability.
|
|||||||
})
|
})
|
||||||
export class TooltipDirective {
|
export class TooltipDirective {
|
||||||
// ngtsc generates this:
|
// ngtsc generates this:
|
||||||
static ngDirectiveDef = ɵɵdefineDirective(...);
|
static ɵdir = ɵɵdefineDirective(...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -22,7 +22,7 @@ export class TooltipDirective {
|
|||||||
})
|
})
|
||||||
class MyAppComponent {
|
class MyAppComponent {
|
||||||
// ngtsc generates this:
|
// ngtsc generates this:
|
||||||
static ngDirectiveDef = ɵɵdefineComponent({
|
static ɵdir = ɵɵdefineComponent({
|
||||||
...
|
...
|
||||||
directives: [
|
directives: [
|
||||||
// BREAKS TREE-SHAKING!!!
|
// BREAKS TREE-SHAKING!!!
|
||||||
@ -41,7 +41,7 @@ class MyAppComponent {
|
|||||||
})
|
})
|
||||||
class MyAppModule {
|
class MyAppModule {
|
||||||
// ngtsc generates this:
|
// ngtsc generates this:
|
||||||
static ngDirectiveDef = ɵɵdefineNgModule(...);
|
static ɵdir = ɵɵdefineNgModule(...);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -52,6 +52,6 @@ We store the information in the `.d.ts` file like so.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class TooltipDirective {
|
class TooltipDirective {
|
||||||
static ngDirectiveDef: DirectiveDefWithMeta<TooltipDirective, '[tooltip]', '', {}, {}, []>
|
static ɵdir: DirectiveDefWithMeta<TooltipDirective, '[tooltip]', '', {}, {}, []>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -172,7 +172,7 @@ class Child {
|
|||||||
})
|
})
|
||||||
class Tooltip {
|
class Tooltip {
|
||||||
@HostBinding('title') hostTitle = 'greeting';
|
@HostBinding('title') hostTitle = 'greeting';
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
...
|
...
|
||||||
hostVars: 1
|
hostVars: 1
|
||||||
});
|
});
|
||||||
@ -206,8 +206,8 @@ The `EXPANDO` section needs additional information for information stored in `TV
|
|||||||
| 1 | 2 | Injector size. Number of values to skip to get to Host Bindings.
|
| 1 | 2 | Injector size. Number of values to skip to get to Host Bindings.
|
||||||
| 2 | Child.ɵcmp.hostBindings | The function to call. (Only when `hostVars` is not `0`)
|
| 2 | Child.ɵcmp.hostBindings | The function to call. (Only when `hostVars` is not `0`)
|
||||||
| 3 | Child.ɵcmp.hostVars | Number of host bindings to process. (Only when `hostVars` is not `0`)
|
| 3 | Child.ɵcmp.hostVars | Number of host bindings to process. (Only when `hostVars` is not `0`)
|
||||||
| 4 | Tooltip.ngDirectiveDef.hostBindings | The function to call. (Only when `hostVars` is not `0`)
|
| 4 | Tooltip.ɵdir.hostBindings | The function to call. (Only when `hostVars` is not `0`)
|
||||||
| 5 | Tooltip.ngDirectiveDef.hostVars | Number of host bindings to process. (Only when `hostVars` is not `0`)
|
| 5 | Tooltip.ɵdir.hostVars | Number of host bindings to process. (Only when `hostVars` is not `0`)
|
||||||
|
|
||||||
The reason for this layout is to make the host binding update efficient using this pseudo code:
|
The reason for this layout is to make the host binding update efficient using this pseudo code:
|
||||||
```typescript
|
```typescript
|
||||||
@ -245,9 +245,9 @@ The above code should execute as:
|
|||||||
| `Child.ɵcmp.hostBindings` | invoke with => | `\* new Child() *\ 19` | `\* <child> *\ 10`
|
| `Child.ɵcmp.hostBindings` | invoke with => | `\* new Child() *\ 19` | `\* <child> *\ 10`
|
||||||
| | `21` | `\* new Tooltip() *\ 20` | `\* <child> *\ 10`
|
| | `21` | `\* new Tooltip() *\ 20` | `\* <child> *\ 10`
|
||||||
| `Child.ɵcmp.hostVars` | `22` | `\* new Tooltip() *\ 20` | `\* <child> *\ 10`
|
| `Child.ɵcmp.hostVars` | `22` | `\* new Tooltip() *\ 20` | `\* <child> *\ 10`
|
||||||
| `Tooltip.ngDirectiveDef.hostBindings` | invoke with => | `\* new Tooltip() *\ 20` | `\* <child> *\ 10`
|
| `Tooltip.ɵdir.hostBindings` | invoke with => | `\* new Tooltip() *\ 20` | `\* <child> *\ 10`
|
||||||
| | `22` | `21` | `\* <child> *\ 10`
|
| | `22` | `21` | `\* <child> *\ 10`
|
||||||
| `Tooltip.ngDirectiveDef.hostVars` | `22` | `21` | `\* <child> *\ 10`
|
| `Tooltip.ɵdir.hostVars` | `22` | `21` | `\* <child> *\ 10`
|
||||||
|
|
||||||
## `EXPANDO` and Injection
|
## `EXPANDO` and Injection
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ export function isComponentInstance(instance: any): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isDirectiveInstance(instance: any): boolean {
|
export function isDirectiveInstance(instance: any): boolean {
|
||||||
return instance && instance.constructor && instance.constructor.ngDirectiveDef;
|
return instance && instance.constructor && instance.constructor.ɵdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ import {initNgDevMode} from '../util/ng_dev_mode';
|
|||||||
import {stringify} from '../util/stringify';
|
import {stringify} from '../util/stringify';
|
||||||
|
|
||||||
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
|
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
|
||||||
import {NG_BASE_DEF, NG_COMP_DEF, NG_DIRECTIVE_DEF, NG_FACTORY_DEF, NG_LOCALE_ID_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
import {NG_BASE_DEF, NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF, NG_LOCALE_ID_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
||||||
import {ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, FactoryFn, HostBindingsFunction, PipeDef, PipeType, PipeTypesOrFactory, ViewQueriesFunction, ɵɵBaseDef} from './interfaces/definition';
|
import {ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, FactoryFn, HostBindingsFunction, PipeDef, PipeType, PipeTypesOrFactory, ViewQueriesFunction, ɵɵBaseDef} from './interfaces/definition';
|
||||||
import {TAttributes} from './interfaces/node';
|
import {TAttributes} from './interfaces/node';
|
||||||
// while SelectorFlags is unused here, it's required so that types don't get resolved lazily
|
// while SelectorFlags is unused here, it's required so that types don't get resolved lazily
|
||||||
@ -593,7 +593,7 @@ export function ɵɵdefineBase<T>(baseDefinition: {
|
|||||||
* class MyDirective {
|
* class MyDirective {
|
||||||
* // Generated by Angular Template Compiler
|
* // Generated by Angular Template Compiler
|
||||||
* // [Symbol] syntax will not be supported by TypeScript until v2.7
|
* // [Symbol] syntax will not be supported by TypeScript until v2.7
|
||||||
* static ngDirectiveDef = ɵɵdefineDirective({
|
* static ɵdir = ɵɵdefineDirective({
|
||||||
* ...
|
* ...
|
||||||
* });
|
* });
|
||||||
* }
|
* }
|
||||||
@ -744,7 +744,7 @@ export function getComponentDef<T>(type: any): ComponentDef<T>|null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getDirectiveDef<T>(type: any): DirectiveDef<T>|null {
|
export function getDirectiveDef<T>(type: any): DirectiveDef<T>|null {
|
||||||
return type[NG_DIRECTIVE_DEF] || null;
|
return type[NG_DIR_DEF] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPipeDef<T>(type: any): PipeDef<T>|null {
|
export function getPipeDef<T>(type: any): PipeDef<T>|null {
|
||||||
|
@ -15,7 +15,7 @@ import {isComponentDef} from '../interfaces/type_checks';
|
|||||||
import {ɵɵNgOnChangesFeature} from './ng_onchanges_feature';
|
import {ɵɵNgOnChangesFeature} from './ng_onchanges_feature';
|
||||||
|
|
||||||
function getSuperType(type: Type<any>): Type<any>&
|
function getSuperType(type: Type<any>): Type<any>&
|
||||||
{ɵcmp?: ComponentDef<any>, ngDirectiveDef?: DirectiveDef<any>} {
|
{ɵcmp?: ComponentDef<any>, ɵdir?: DirectiveDef<any>} {
|
||||||
return Object.getPrototypeOf(type.prototype).constructor;
|
return Object.getPrototypeOf(type.prototype).constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,13 +32,13 @@ export function ɵɵInheritDefinitionFeature(definition: DirectiveDef<any>| Comp
|
|||||||
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
|
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
|
||||||
if (isComponentDef(definition)) {
|
if (isComponentDef(definition)) {
|
||||||
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
||||||
superDef = superType.ɵcmp || superType.ngDirectiveDef;
|
superDef = superType.ɵcmp || superType.ɵdir;
|
||||||
} else {
|
} else {
|
||||||
if (superType.ɵcmp) {
|
if (superType.ɵcmp) {
|
||||||
throw new Error('Directives cannot inherit Components');
|
throw new Error('Directives cannot inherit Components');
|
||||||
}
|
}
|
||||||
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
||||||
superDef = superType.ngDirectiveDef;
|
superDef = superType.ɵdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseDef = (superType as any).ngBaseDef;
|
const baseDef = (superType as any).ngBaseDef;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {getClosureSafeProperty} from '../util/property';
|
import {getClosureSafeProperty} from '../util/property';
|
||||||
|
|
||||||
export const NG_COMP_DEF = getClosureSafeProperty({ɵcmp: getClosureSafeProperty});
|
export const NG_COMP_DEF = getClosureSafeProperty({ɵcmp: getClosureSafeProperty});
|
||||||
export const NG_DIRECTIVE_DEF = getClosureSafeProperty({ngDirectiveDef: getClosureSafeProperty});
|
export const NG_DIR_DEF = getClosureSafeProperty({ɵdir: getClosureSafeProperty});
|
||||||
export const NG_PIPE_DEF = getClosureSafeProperty({ngPipeDef: getClosureSafeProperty});
|
export const NG_PIPE_DEF = getClosureSafeProperty({ngPipeDef: getClosureSafeProperty});
|
||||||
export const NG_MODULE_DEF = getClosureSafeProperty({ngModuleDef: getClosureSafeProperty});
|
export const NG_MODULE_DEF = getClosureSafeProperty({ngModuleDef: getClosureSafeProperty});
|
||||||
export const NG_LOCALE_ID_DEF = getClosureSafeProperty({ngLocaleIdDef: getClosureSafeProperty});
|
export const NG_LOCALE_ID_DEF = getClosureSafeProperty({ngLocaleIdDef: getClosureSafeProperty});
|
||||||
|
@ -24,7 +24,7 @@ import {getLView, getPreviousOrParentTNode} from '../state';
|
|||||||
* class SomeDirective {
|
* class SomeDirective {
|
||||||
* constructor(directive: DirectiveA) {}
|
* constructor(directive: DirectiveA) {}
|
||||||
*
|
*
|
||||||
* static ngDirectiveDef = ɵɵdefineDirective({
|
* static ɵdir = ɵɵdefineDirective({
|
||||||
* type: SomeDirective,
|
* type: SomeDirective,
|
||||||
* factory: () => new SomeDirective(ɵɵdirectiveInject(DirectiveA))
|
* factory: () => new SomeDirective(ɵɵdirectiveInject(DirectiveA))
|
||||||
* });
|
* });
|
||||||
|
@ -75,11 +75,11 @@ export const enum RenderFlags {
|
|||||||
export interface ComponentType<T> extends Type<T> { ɵcmp: never; }
|
export interface ComponentType<T> extends Type<T> { ɵcmp: never; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A subclass of `Type` which has a static `ngDirectiveDef`:`DirectiveDef` field making it
|
* A subclass of `Type` which has a static `ɵdir`:`DirectiveDef` field making it
|
||||||
* consumable for rendering.
|
* consumable for rendering.
|
||||||
*/
|
*/
|
||||||
export interface DirectiveType<T> extends Type<T> {
|
export interface DirectiveType<T> extends Type<T> {
|
||||||
ngDirectiveDef: never;
|
ɵdir: never;
|
||||||
ngFactoryDef: () => T;
|
ngFactoryDef: () => T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import {ViewEncapsulation} from '../../metadata/view';
|
|||||||
import {initNgDevMode} from '../../util/ng_dev_mode';
|
import {initNgDevMode} from '../../util/ng_dev_mode';
|
||||||
import {getBaseDef, getComponentDef, getDirectiveDef} from '../definition';
|
import {getBaseDef, getComponentDef, getDirectiveDef} from '../definition';
|
||||||
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
|
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
|
||||||
import {NG_BASE_DEF, NG_COMP_DEF, NG_DIRECTIVE_DEF, NG_FACTORY_DEF} from '../fields';
|
import {NG_BASE_DEF, NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF} from '../fields';
|
||||||
import {ComponentType} from '../interfaces/definition';
|
import {ComponentType} from '../interfaces/definition';
|
||||||
import {stringifyForError} from '../util/misc_utils';
|
import {stringifyForError} from '../util/misc_utils';
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ function hasSelectorScope<T>(component: Type<T>): component is Type<T>&
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile an Angular directive according to its decorator metadata, and patch the resulting
|
* Compile an Angular directive according to its decorator metadata, and patch the resulting
|
||||||
* ngDirectiveDef onto the component type.
|
* directive def onto the component type.
|
||||||
*
|
*
|
||||||
* In the event that compilation is not immediate, `compileDirective` will return a `Promise` which
|
* In the event that compilation is not immediate, `compileDirective` will return a `Promise` which
|
||||||
* will resolve when compilation completes and the directive becomes usable.
|
* will resolve when compilation completes and the directive becomes usable.
|
||||||
@ -129,7 +129,7 @@ export function compileDirective(type: Type<any>, directive: Directive | null):
|
|||||||
|
|
||||||
addDirectiveFactoryDef(type, directive || {});
|
addDirectiveFactoryDef(type, directive || {});
|
||||||
|
|
||||||
Object.defineProperty(type, NG_DIRECTIVE_DEF, {
|
Object.defineProperty(type, NG_DIR_DEF, {
|
||||||
get: () => {
|
get: () => {
|
||||||
if (ngDirectiveDef === null) {
|
if (ngDirectiveDef === null) {
|
||||||
// `directive` can be null in the case of abstract directives as a base class
|
// `directive` can be null in the case of abstract directives as a base class
|
||||||
@ -148,7 +148,7 @@ export function compileDirective(type: Type<any>, directive: Directive | null):
|
|||||||
|
|
||||||
function getDirectiveMetadata(type: Type<any>, metadata: Directive) {
|
function getDirectiveMetadata(type: Type<any>, metadata: Directive) {
|
||||||
const name = type && type.name;
|
const name = type && type.name;
|
||||||
const sourceMapUrl = `ng:///${name}/ngDirectiveDef.js`;
|
const sourceMapUrl = `ng:///${name}/ɵdir.js`;
|
||||||
const compiler = getCompilerFacade();
|
const compiler = getCompilerFacade();
|
||||||
const facade = directiveMetadata(type as ComponentType<any>, metadata);
|
const facade = directiveMetadata(type as ComponentType<any>, metadata);
|
||||||
facade.typeSourceSpan = compiler.createParseSourceSpan('Directive', name, sourceMapUrl);
|
facade.typeSourceSpan = compiler.createParseSourceSpan('Directive', name, sourceMapUrl);
|
||||||
|
@ -16,7 +16,7 @@ import {ModuleWithProviders, NgModule, NgModuleDef, NgModuleTransitiveScopes} fr
|
|||||||
import {deepForEach, flatten} from '../../util/array_utils';
|
import {deepForEach, flatten} from '../../util/array_utils';
|
||||||
import {assertDefined} from '../../util/assert';
|
import {assertDefined} from '../../util/assert';
|
||||||
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
|
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
|
||||||
import {NG_COMP_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields';
|
import {NG_COMP_DEF, NG_DIR_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields';
|
||||||
import {ComponentDef} from '../interfaces/definition';
|
import {ComponentDef} from '../interfaces/definition';
|
||||||
import {NgModuleType} from '../ng_module_ref';
|
import {NgModuleType} from '../ng_module_ref';
|
||||||
import {maybeUnwrapFn, stringifyForError} from '../util/misc_utils';
|
import {maybeUnwrapFn, stringifyForError} from '../util/misc_utils';
|
||||||
@ -388,7 +388,7 @@ function setScopeOnDeclaredComponents(moduleType: Type<any>, ngModule: NgModule)
|
|||||||
const componentDef = getComponentDef(component) !;
|
const componentDef = getComponentDef(component) !;
|
||||||
patchComponentDefWithScope(componentDef, transitiveScopes);
|
patchComponentDefWithScope(componentDef, transitiveScopes);
|
||||||
} else if (
|
} else if (
|
||||||
!declaration.hasOwnProperty(NG_DIRECTIVE_DEF) && !declaration.hasOwnProperty(NG_PIPE_DEF)) {
|
!declaration.hasOwnProperty(NG_DIR_DEF) && !declaration.hasOwnProperty(NG_PIPE_DEF)) {
|
||||||
// Set `ngSelectorScope` for future reference when the component compilation finishes.
|
// Set `ngSelectorScope` for future reference when the component compilation finishes.
|
||||||
(declaration as Type<any>& {ngSelectorScope?: any}).ngSelectorScope = moduleType;
|
(declaration as Type<any>& {ngSelectorScope?: any}).ngSelectorScope = moduleType;
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ export function transitiveScopesFor<T>(
|
|||||||
if (getPipeDef(declaredWithDefs)) {
|
if (getPipeDef(declaredWithDefs)) {
|
||||||
scopes.compilation.pipes.add(declared);
|
scopes.compilation.pipes.add(declared);
|
||||||
} else {
|
} else {
|
||||||
// Either declared has a ɵcmp or ngDirectiveDef, or it's a component which hasn't
|
// Either declared has a ɵcmp or ɵdir, or it's a component which hasn't
|
||||||
// had its template compiled yet. In either case, it gets added to the compilation's
|
// had its template compiled yet. In either case, it gets added to the compilation's
|
||||||
// directives.
|
// directives.
|
||||||
scopes.compilation.directives.add(declared);
|
scopes.compilation.directives.add(declared);
|
||||||
@ -487,7 +487,7 @@ export function transitiveScopesFor<T>(
|
|||||||
const exportedType = exported as Type<E>& {
|
const exportedType = exported as Type<E>& {
|
||||||
// Components, Directives, NgModules, and Pipes can all be exported.
|
// Components, Directives, NgModules, and Pipes can all be exported.
|
||||||
ɵcmp?: any;
|
ɵcmp?: any;
|
||||||
ngDirectiveDef?: any;
|
ɵdir?: any;
|
||||||
ngModuleDef?: NgModuleDef<E>;
|
ngModuleDef?: NgModuleDef<E>;
|
||||||
ngPipeDef?: any;
|
ngPipeDef?: any;
|
||||||
};
|
};
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
"name": "NG_COMP_DEF"
|
"name": "NG_COMP_DEF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_DIRECTIVE_DEF"
|
"name": "NG_DIR_DEF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_ELEMENT_ID"
|
"name": "NG_ELEMENT_ID"
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
"name": "NG_COMP_DEF"
|
"name": "NG_COMP_DEF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_DIRECTIVE_DEF"
|
"name": "NG_DIR_DEF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_ELEMENT_ID"
|
"name": "NG_ELEMENT_ID"
|
||||||
|
@ -126,7 +126,7 @@
|
|||||||
"name": "NG_COMP_DEF"
|
"name": "NG_COMP_DEF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_DIRECTIVE_DEF"
|
"name": "NG_DIR_DEF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_ELEMENT_ID"
|
"name": "NG_ELEMENT_ID"
|
||||||
|
@ -15,7 +15,7 @@ export const NgForOf: DirectiveType<NgForOfDef<any>> = NgForOfDef as any;
|
|||||||
export const NgIf: DirectiveType<NgIfDef> = NgIfDef as any;
|
export const NgIf: DirectiveType<NgIfDef> = NgIfDef as any;
|
||||||
export const NgTemplateOutlet: DirectiveType<NgTemplateOutletDef> = NgTemplateOutletDef as any;
|
export const NgTemplateOutlet: DirectiveType<NgTemplateOutletDef> = NgTemplateOutletDef as any;
|
||||||
|
|
||||||
NgForOf.ngDirectiveDef = ɵɵdefineDirective({
|
NgForOf.ɵdir = ɵɵdefineDirective({
|
||||||
type: NgForOfDef,
|
type: NgForOfDef,
|
||||||
selectors: [['', 'ngForOf', '']],
|
selectors: [['', 'ngForOf', '']],
|
||||||
inputs: {
|
inputs: {
|
||||||
@ -29,7 +29,7 @@ NgForOf.ngFactoryDef = () => new NgForOfDef(
|
|||||||
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any),
|
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any),
|
||||||
ɵɵdirectiveInject(IterableDiffers));
|
ɵɵdirectiveInject(IterableDiffers));
|
||||||
|
|
||||||
NgIf.ngDirectiveDef = ɵɵdefineDirective({
|
NgIf.ɵdir = ɵɵdefineDirective({
|
||||||
type: NgIfDef,
|
type: NgIfDef,
|
||||||
selectors: [['', 'ngIf', '']],
|
selectors: [['', 'ngIf', '']],
|
||||||
inputs: {ngIf: 'ngIf', ngIfThen: 'ngIfThen', ngIfElse: 'ngIfElse'}
|
inputs: {ngIf: 'ngIf', ngIfThen: 'ngIfThen', ngIfElse: 'ngIfElse'}
|
||||||
@ -38,7 +38,7 @@ NgIf.ngDirectiveDef = ɵɵdefineDirective({
|
|||||||
NgIf.ngFactoryDef = () =>
|
NgIf.ngFactoryDef = () =>
|
||||||
new NgIfDef(ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any));
|
new NgIfDef(ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any));
|
||||||
|
|
||||||
NgTemplateOutlet.ngDirectiveDef = ɵɵdefineDirective({
|
NgTemplateOutlet.ɵdir = ɵɵdefineDirective({
|
||||||
type: NgTemplateOutletDef,
|
type: NgTemplateOutletDef,
|
||||||
selectors: [['', 'ngTemplateOutlet', '']],
|
selectors: [['', 'ngTemplateOutlet', '']],
|
||||||
features: [ɵɵNgOnChangesFeature()],
|
features: [ɵɵNgOnChangesFeature()],
|
||||||
|
@ -437,8 +437,7 @@ describe('recursive components', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(NgIfTree.ɵcmp as ComponentDef<NgIfTree>).directiveDefs =
|
(NgIfTree.ɵcmp as ComponentDef<NgIfTree>).directiveDefs = () => [NgIfTree.ɵcmp, NgIf.ɵdir];
|
||||||
() => [NgIfTree.ɵcmp, NgIf.ngDirectiveDef];
|
|
||||||
|
|
||||||
function _buildTree(currDepth: number): TreeNode {
|
function _buildTree(currDepth: number): TreeNode {
|
||||||
const children = currDepth < 2 ? _buildTree(currDepth + 1) : null;
|
const children = currDepth < 2 ? _buildTree(currDepth + 1) : null;
|
||||||
|
@ -29,7 +29,7 @@ describe('di', () => {
|
|||||||
value = 'DirB';
|
value = 'DirB';
|
||||||
|
|
||||||
static ngFactoryDef = () => new DirB();
|
static ngFactoryDef = () => new DirB();
|
||||||
static ngDirectiveDef =
|
static ɵdir =
|
||||||
ɵɵdefineDirective({selectors: [['', 'dirB', '']], type: DirB, inputs: {value: 'value'}});
|
ɵɵdefineDirective({selectors: [['', 'dirB', '']], type: DirB, inputs: {value: 'value'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ describe('di', () => {
|
|||||||
value !: string;
|
value !: string;
|
||||||
|
|
||||||
static ngFactoryDef = () => new DirB();
|
static ngFactoryDef = () => new DirB();
|
||||||
static ngDirectiveDef =
|
static ɵdir =
|
||||||
ɵɵdefineDirective({type: DirB, selectors: [['', 'dirB', '']], inputs: {value: 'dirB'}});
|
ɵɵdefineDirective({type: DirB, selectors: [['', 'dirB', '']], inputs: {value: 'dirB'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ describe('di', () => {
|
|||||||
return dirA;
|
return dirA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({type: DirA, selectors: [['', 'dirA', '']]});
|
static ɵdir = ɵɵdefineDirective({type: DirA, selectors: [['', 'dirA', '']]});
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => dirA = null);
|
beforeEach(() => dirA = null);
|
||||||
@ -82,7 +82,7 @@ describe('di', () => {
|
|||||||
constructor(@Self() public dirB: DirB) {}
|
constructor(@Self() public dirB: DirB) {}
|
||||||
|
|
||||||
static ngFactoryDef = () => dirA = new DirA(ɵɵdirectiveInject(DirB, InjectFlags.Self));
|
static ngFactoryDef = () => dirA = new DirA(ɵɵdirectiveInject(DirB, InjectFlags.Self));
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({type: DirA, selectors: [['', 'dirA', '']]});
|
static ɵdir = ɵɵdefineDirective({type: DirA, selectors: [['', 'dirA', '']]});
|
||||||
}
|
}
|
||||||
|
|
||||||
const DirC = createDirective('dirC');
|
const DirC = createDirective('dirC');
|
||||||
|
@ -346,7 +346,7 @@ describe('component animations', () => {
|
|||||||
// it('should allow host binding animations to be picked up and rendered', () => {
|
// it('should allow host binding animations to be picked up and rendered', () => {
|
||||||
// class ChildCompWithAnim {
|
// class ChildCompWithAnim {
|
||||||
// static ngFactoryDef = () => new ChildCompWithAnim();
|
// static ngFactoryDef = () => new ChildCompWithAnim();
|
||||||
// static ngDirectiveDef = ɵɵdefineDirective({
|
// static ɵdir = ɵɵdefineDirective({
|
||||||
// type: ChildCompWithAnim,
|
// type: ChildCompWithAnim,
|
||||||
// selectors: [['child-comp-with-anim']],
|
// selectors: [['child-comp-with-anim']],
|
||||||
// hostBindings: function(rf: RenderFlags, ctx: any, elementIndex: number): void {
|
// hostBindings: function(rf: RenderFlags, ctx: any, elementIndex: number): void {
|
||||||
@ -837,20 +837,17 @@ describe('element discovery', () => {
|
|||||||
|
|
||||||
class MyDir1 {
|
class MyDir1 {
|
||||||
static ngFactoryDef = () => myDir1Instance = new MyDir1();
|
static ngFactoryDef = () => myDir1Instance = new MyDir1();
|
||||||
static ngDirectiveDef =
|
static ɵdir = ɵɵdefineDirective({type: MyDir1, selectors: [['', 'my-dir-1', '']]});
|
||||||
ɵɵdefineDirective({type: MyDir1, selectors: [['', 'my-dir-1', '']]});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyDir2 {
|
class MyDir2 {
|
||||||
static ngFactoryDef = () => myDir2Instance = new MyDir2();
|
static ngFactoryDef = () => myDir2Instance = new MyDir2();
|
||||||
static ngDirectiveDef =
|
static ɵdir = ɵɵdefineDirective({type: MyDir2, selectors: [['', 'my-dir-2', '']]});
|
||||||
ɵɵdefineDirective({type: MyDir2, selectors: [['', 'my-dir-2', '']]});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyDir3 {
|
class MyDir3 {
|
||||||
static ngFactoryDef = () => myDir3Instance = new MyDir2();
|
static ngFactoryDef = () => myDir3Instance = new MyDir2();
|
||||||
static ngDirectiveDef =
|
static ɵdir = ɵɵdefineDirective({type: MyDir3, selectors: [['', 'my-dir-3', '']]});
|
||||||
ɵɵdefineDirective({type: MyDir3, selectors: [['', 'my-dir-3', '']]});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class StructuredComp {
|
class StructuredComp {
|
||||||
@ -921,14 +918,12 @@ describe('element discovery', () => {
|
|||||||
|
|
||||||
class MyDir1 {
|
class MyDir1 {
|
||||||
static ngFactoryDef = () => myDir1Instance = new MyDir1();
|
static ngFactoryDef = () => myDir1Instance = new MyDir1();
|
||||||
static ngDirectiveDef =
|
static ɵdir = ɵɵdefineDirective({type: MyDir1, selectors: [['', 'my-dir-1', '']]});
|
||||||
ɵɵdefineDirective({type: MyDir1, selectors: [['', 'my-dir-1', '']]});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyDir2 {
|
class MyDir2 {
|
||||||
static ngFactoryDef = () => myDir2Instance = new MyDir2();
|
static ngFactoryDef = () => myDir2Instance = new MyDir2();
|
||||||
static ngDirectiveDef =
|
static ɵdir = ɵɵdefineDirective({type: MyDir2, selectors: [['', 'my-dir-2', '']]});
|
||||||
ɵɵdefineDirective({type: MyDir2, selectors: [['', 'my-dir-2', '']]});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChildComp {
|
class ChildComp {
|
||||||
@ -1114,7 +1109,7 @@ describe('sanitization', () => {
|
|||||||
cite: any = 'http://cite-dir-value';
|
cite: any = 'http://cite-dir-value';
|
||||||
|
|
||||||
static ngFactoryDef = () => hostBindingDir = new UnsafeUrlHostBindingDir();
|
static ngFactoryDef = () => hostBindingDir = new UnsafeUrlHostBindingDir();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: UnsafeUrlHostBindingDir,
|
type: UnsafeUrlHostBindingDir,
|
||||||
selectors: [['', 'unsafeUrlHostBindingDir', '']],
|
selectors: [['', 'unsafeUrlHostBindingDir', '']],
|
||||||
hostBindings: (rf: RenderFlags, ctx: any) => {
|
hostBindings: (rf: RenderFlags, ctx: any) => {
|
||||||
|
@ -281,8 +281,8 @@ ivyEnabled && describe('render3 jit', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const InputDirAny = InputDir as any;
|
const InputDirAny = InputDir as any;
|
||||||
expect(InputDirAny.ngDirectiveDef.inputs).toEqual({publicName: 'privateName'});
|
expect(InputDirAny.ɵdir.inputs).toEqual({publicName: 'privateName'});
|
||||||
expect(InputDirAny.ngDirectiveDef.declaredInputs).toEqual({publicName: 'privateName'});
|
expect(InputDirAny.ɵdir.declaredInputs).toEqual({publicName: 'privateName'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should compile ContentChildren query with string predicate on a directive', () => {
|
it('should compile ContentChildren query with string predicate on a directive', () => {
|
||||||
@ -291,7 +291,7 @@ ivyEnabled && describe('render3 jit', () => {
|
|||||||
@ContentChildren('foo') foos: QueryList<ElementRef>|undefined;
|
@ContentChildren('foo') foos: QueryList<ElementRef>|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect((TestDirective as any).ngDirectiveDef.contentQueries).not.toBeNull();
|
expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should compile ContentChild query with string predicate on a directive', () => {
|
it('should compile ContentChild query with string predicate on a directive', () => {
|
||||||
@ -300,7 +300,7 @@ ivyEnabled && describe('render3 jit', () => {
|
|||||||
@ContentChild('foo', {static: false}) foo: ElementRef|undefined;
|
@ContentChild('foo', {static: false}) foo: ElementRef|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect((TestDirective as any).ngDirectiveDef.contentQueries).not.toBeNull();
|
expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should compile ContentChildren query with type predicate on a directive', () => {
|
it('should compile ContentChildren query with type predicate on a directive', () => {
|
||||||
@ -311,7 +311,7 @@ ivyEnabled && describe('render3 jit', () => {
|
|||||||
@ContentChildren(SomeDir) dirs: QueryList<SomeDir>|undefined;
|
@ContentChildren(SomeDir) dirs: QueryList<SomeDir>|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect((TestDirective as any).ngDirectiveDef.contentQueries).not.toBeNull();
|
expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should compile ContentChild query with type predicate on a directive', () => {
|
it('should compile ContentChild query with type predicate on a directive', () => {
|
||||||
@ -322,7 +322,7 @@ ivyEnabled && describe('render3 jit', () => {
|
|||||||
@ContentChild(SomeDir, {static: false}) dir: SomeDir|undefined;
|
@ContentChild(SomeDir, {static: false}) dir: SomeDir|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect((TestDirective as any).ngDirectiveDef.contentQueries).not.toBeNull();
|
expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should compile ViewChild query on a component', () => {
|
it('should compile ViewChild query on a component', () => {
|
||||||
|
@ -71,7 +71,7 @@ describe('lifecycles', () => {
|
|||||||
ngOnInit() { events.push('dir'); }
|
ngOnInit() { events.push('dir'); }
|
||||||
|
|
||||||
static ngFactoryDef = () => new Directive();
|
static ngFactoryDef = () => new Directive();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({type: Directive, selectors: [['', 'dir', '']]});
|
static ɵdir = ɵɵdefineDirective({type: Directive, selectors: [['', 'dir', '']]});
|
||||||
}
|
}
|
||||||
|
|
||||||
const directives = [Comp, Parent, ProjectedComp, Directive, NgIf];
|
const directives = [Comp, Parent, ProjectedComp, Directive, NgIf];
|
||||||
|
@ -101,7 +101,7 @@ describe('event listeners', () => {
|
|||||||
static ngFactoryDef = function HostListenerDir_Factory() {
|
static ngFactoryDef = function HostListenerDir_Factory() {
|
||||||
return new GlobalHostListenerDir();
|
return new GlobalHostListenerDir();
|
||||||
};
|
};
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: GlobalHostListenerDir,
|
type: GlobalHostListenerDir,
|
||||||
selectors: [['', 'hostListenerDir', '']],
|
selectors: [['', 'hostListenerDir', '']],
|
||||||
hostBindings: function HostListenerDir_HostBindings(
|
hostBindings: function HostListenerDir_HostBindings(
|
||||||
@ -581,7 +581,7 @@ describe('event listeners', () => {
|
|||||||
onClick() { events.push('click!'); }
|
onClick() { events.push('click!'); }
|
||||||
|
|
||||||
static ngFactoryDef = function HostListenerDir_Factory() { return new HostListenerDir(); };
|
static ngFactoryDef = function HostListenerDir_Factory() { return new HostListenerDir(); };
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: HostListenerDir,
|
type: HostListenerDir,
|
||||||
selectors: [['', 'hostListenerDir', '']],
|
selectors: [['', 'hostListenerDir', '']],
|
||||||
hostBindings: function HostListenerDir_HostBindings(
|
hostBindings: function HostListenerDir_HostBindings(
|
||||||
|
@ -38,7 +38,7 @@ describe('outputs', () => {
|
|||||||
changeStream = new EventEmitter();
|
changeStream = new EventEmitter();
|
||||||
|
|
||||||
static ngFactoryDef = () => otherDir = new OtherDir;
|
static ngFactoryDef = () => otherDir = new OtherDir;
|
||||||
static ngDirectiveDef = ɵɵdefineDirective(
|
static ɵdir = ɵɵdefineDirective(
|
||||||
{type: OtherDir, selectors: [['', 'otherDir', '']], outputs: {changeStream: 'change'}});
|
{type: OtherDir, selectors: [['', 'otherDir', '']], outputs: {changeStream: 'change'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1459,7 +1459,7 @@ function expectProvidersScenario(defs: {
|
|||||||
|
|
||||||
class ViewChildDirective {
|
class ViewChildDirective {
|
||||||
static ngFactoryDef = () => testDirectiveInjection(defs.viewChild, new ViewChildDirective());
|
static ngFactoryDef = () => testDirectiveInjection(defs.viewChild, new ViewChildDirective());
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: ViewChildDirective,
|
type: ViewChildDirective,
|
||||||
selectors: [['view-child']],
|
selectors: [['view-child']],
|
||||||
features: defs.viewChild && [ɵɵProvidersFeature(defs.viewChild.directiveProviders || [])],
|
features: defs.viewChild && [ɵɵProvidersFeature(defs.viewChild.directiveProviders || [])],
|
||||||
@ -1490,7 +1490,7 @@ function expectProvidersScenario(defs: {
|
|||||||
static ngFactoryDef =
|
static ngFactoryDef =
|
||||||
() => { return testDirectiveInjection(defs.contentChild, new ContentChildDirective()); }
|
() => { return testDirectiveInjection(defs.contentChild, new ContentChildDirective()); }
|
||||||
|
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: ContentChildDirective,
|
type: ContentChildDirective,
|
||||||
selectors: [['content-child']],
|
selectors: [['content-child']],
|
||||||
features:
|
features:
|
||||||
@ -1519,7 +1519,7 @@ function expectProvidersScenario(defs: {
|
|||||||
|
|
||||||
class ParentDirective {
|
class ParentDirective {
|
||||||
static ngFactoryDef = () => testDirectiveInjection(defs.parent, new ParentDirective());
|
static ngFactoryDef = () => testDirectiveInjection(defs.parent, new ParentDirective());
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: ParentDirective,
|
type: ParentDirective,
|
||||||
selectors: [['parent']],
|
selectors: [['parent']],
|
||||||
features: defs.parent && [ɵɵProvidersFeature(defs.parent.directiveProviders || [])],
|
features: defs.parent && [ɵɵProvidersFeature(defs.parent.directiveProviders || [])],
|
||||||
@ -1528,7 +1528,7 @@ function expectProvidersScenario(defs: {
|
|||||||
|
|
||||||
class ParentDirective2 {
|
class ParentDirective2 {
|
||||||
static ngFactoryDef = () => testDirectiveInjection(defs.parent, new ParentDirective2());
|
static ngFactoryDef = () => testDirectiveInjection(defs.parent, new ParentDirective2());
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: ParentDirective2,
|
type: ParentDirective2,
|
||||||
selectors: [['parent']],
|
selectors: [['parent']],
|
||||||
features: defs.parent && [ɵɵProvidersFeature(defs.parent.directive2Providers || [])],
|
features: defs.parent && [ɵɵProvidersFeature(defs.parent.directive2Providers || [])],
|
||||||
|
@ -223,7 +223,7 @@ describe('query', () => {
|
|||||||
static ngFactoryDef = function MyDirective_Factory() {
|
static ngFactoryDef = function MyDirective_Factory() {
|
||||||
return directive = new MyDirective(ɵɵdirectiveInject(Service));
|
return directive = new MyDirective(ɵɵdirectiveInject(Service));
|
||||||
};
|
};
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: MyDirective,
|
type: MyDirective,
|
||||||
selectors: [['', 'myDir', '']],
|
selectors: [['', 'myDir', '']],
|
||||||
features: [ɵɵProvidersFeature([Service, {provide: Alias, useExisting: Service}])],
|
features: [ɵɵProvidersFeature([Service, {provide: Alias, useExisting: Service}])],
|
||||||
@ -1423,7 +1423,7 @@ describe('query', () => {
|
|||||||
static ngFactoryDef = () => new SomeDir(
|
static ngFactoryDef = () => new SomeDir(
|
||||||
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any))
|
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any))
|
||||||
|
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: SomeDir,
|
type: SomeDir,
|
||||||
selectors: [['', 'someDir', '']],
|
selectors: [['', 'someDir', '']],
|
||||||
});
|
});
|
||||||
@ -1482,7 +1482,7 @@ describe('query', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ngFactoryDef = () => withContentInstance = new WithContentDirective();
|
static ngFactoryDef = () => withContentInstance = new WithContentDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: WithContentDirective,
|
type: WithContentDirective,
|
||||||
selectors: [['', 'with-content', '']],
|
selectors: [['', 'with-content', '']],
|
||||||
contentQueries: (rf: RenderFlags, ctx: any, dirIndex: number) => {
|
contentQueries: (rf: RenderFlags, ctx: any, dirIndex: number) => {
|
||||||
@ -1680,7 +1680,7 @@ describe('query', () => {
|
|||||||
class QueryDirective {
|
class QueryDirective {
|
||||||
fooBars: any;
|
fooBars: any;
|
||||||
static ngFactoryDef = () => new QueryDirective();
|
static ngFactoryDef = () => new QueryDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: QueryDirective,
|
type: QueryDirective,
|
||||||
selectors: [['', 'query', '']],
|
selectors: [['', 'query', '']],
|
||||||
exportAs: ['query'],
|
exportAs: ['query'],
|
||||||
@ -1746,7 +1746,7 @@ describe('query', () => {
|
|||||||
class QueryDirective {
|
class QueryDirective {
|
||||||
fooBars: any;
|
fooBars: any;
|
||||||
static ngFactoryDef = () => new QueryDirective();
|
static ngFactoryDef = () => new QueryDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: QueryDirective,
|
type: QueryDirective,
|
||||||
selectors: [['', 'query', '']],
|
selectors: [['', 'query', '']],
|
||||||
exportAs: ['query'],
|
exportAs: ['query'],
|
||||||
@ -1803,7 +1803,7 @@ describe('query', () => {
|
|||||||
class QueryDirective {
|
class QueryDirective {
|
||||||
fooBars: any;
|
fooBars: any;
|
||||||
static ngFactoryDef = () => new QueryDirective();
|
static ngFactoryDef = () => new QueryDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: QueryDirective,
|
type: QueryDirective,
|
||||||
selectors: [['', 'query', '']],
|
selectors: [['', 'query', '']],
|
||||||
exportAs: ['query'],
|
exportAs: ['query'],
|
||||||
@ -1864,7 +1864,7 @@ describe('query', () => {
|
|||||||
class ShallowQueryDirective {
|
class ShallowQueryDirective {
|
||||||
foos: any;
|
foos: any;
|
||||||
static ngFactoryDef = () => new ShallowQueryDirective();
|
static ngFactoryDef = () => new ShallowQueryDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: ShallowQueryDirective,
|
type: ShallowQueryDirective,
|
||||||
selectors: [['', 'shallow-query', '']],
|
selectors: [['', 'shallow-query', '']],
|
||||||
exportAs: ['shallow-query'],
|
exportAs: ['shallow-query'],
|
||||||
@ -1885,7 +1885,7 @@ describe('query', () => {
|
|||||||
class DeepQueryDirective {
|
class DeepQueryDirective {
|
||||||
foos: any;
|
foos: any;
|
||||||
static ngFactoryDef = () => new DeepQueryDirective();
|
static ngFactoryDef = () => new DeepQueryDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: DeepQueryDirective,
|
type: DeepQueryDirective,
|
||||||
selectors: [['', 'deep-query', '']],
|
selectors: [['', 'deep-query', '']],
|
||||||
exportAs: ['deep-query'],
|
exportAs: ['deep-query'],
|
||||||
@ -1947,7 +1947,7 @@ describe('query', () => {
|
|||||||
value !: string;
|
value !: string;
|
||||||
|
|
||||||
static ngFactoryDef = () => new TextDirective();
|
static ngFactoryDef = () => new TextDirective();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective(
|
static ɵdir = ɵɵdefineDirective(
|
||||||
{type: TextDirective, selectors: [['', 'text', '']], inputs: {value: 'text'}});
|
{type: TextDirective, selectors: [['', 'text', '']], inputs: {value: 'text'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ export function createDirective(
|
|||||||
name: string, {exportAs}: {exportAs?: string[]} = {}): DirectiveType<any> {
|
name: string, {exportAs}: {exportAs?: string[]} = {}): DirectiveType<any> {
|
||||||
return class Directive {
|
return class Directive {
|
||||||
static ngFactoryDef = () => new Directive();
|
static ngFactoryDef = () => new Directive();
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: Directive,
|
type: Directive,
|
||||||
selectors: [['', name, '']],
|
selectors: [['', name, '']],
|
||||||
exportAs: exportAs,
|
exportAs: exportAs,
|
||||||
|
@ -32,7 +32,7 @@ describe('ViewContainerRef', () => {
|
|||||||
static ngFactoryDef = () => directiveInstance = new DirectiveWithVCRef(
|
static ngFactoryDef = () => directiveInstance = new DirectiveWithVCRef(
|
||||||
ɵɵdirectiveInject(ViewContainerRef as any), injectComponentFactoryResolver())
|
ɵɵdirectiveInject(ViewContainerRef as any), injectComponentFactoryResolver())
|
||||||
|
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: DirectiveWithVCRef,
|
type: DirectiveWithVCRef,
|
||||||
selectors: [['', 'vcref', '']],
|
selectors: [['', 'vcref', '']],
|
||||||
inputs: {tplRef: 'tplRef', name: 'name'}
|
inputs: {tplRef: 'tplRef', name: 'name'}
|
||||||
@ -68,7 +68,7 @@ describe('ViewContainerRef', () => {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ngDirectiveDef = ɵɵdefineDirective({
|
static ɵdir = ɵɵdefineDirective({
|
||||||
type: TestDirective,
|
type: TestDirective,
|
||||||
selectors: [['', 'testdir', '']],
|
selectors: [['', 'testdir', '']],
|
||||||
});
|
});
|
||||||
@ -140,7 +140,7 @@ describe('ViewContainerRef', () => {
|
|||||||
static ngFactoryDef = () => directiveInstance = new TestDirective(
|
static ngFactoryDef = () => directiveInstance = new TestDirective(
|
||||||
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any))
|
ɵɵdirectiveInject(ViewContainerRef as any), ɵɵdirectiveInject(TemplateRef as any))
|
||||||
|
|
||||||
static ngDirectiveDef =
|
static ɵdir =
|
||||||
ɵɵdefineDirective({type: TestDirective, selectors: [['', 'testdir', '']]});
|
ɵɵdefineDirective({type: TestDirective, selectors: [['', 'testdir', '']]});
|
||||||
|
|
||||||
constructor(private _vcRef: ViewContainerRef, private _tplRef: TemplateRef<{}>) {}
|
constructor(private _vcRef: ViewContainerRef, private _tplRef: TemplateRef<{}>) {}
|
||||||
|
@ -657,8 +657,8 @@ describe('TestBed', () => {
|
|||||||
expect(ComponentWithNoAnnotations.hasOwnProperty('ɵcmp')).toBeTruthy();
|
expect(ComponentWithNoAnnotations.hasOwnProperty('ɵcmp')).toBeTruthy();
|
||||||
expect(SomeComponent.hasOwnProperty('ɵcmp')).toBeTruthy();
|
expect(SomeComponent.hasOwnProperty('ɵcmp')).toBeTruthy();
|
||||||
|
|
||||||
expect(DirectiveWithNoAnnotations.hasOwnProperty('ngDirectiveDef')).toBeTruthy();
|
expect(DirectiveWithNoAnnotations.hasOwnProperty('ɵdir')).toBeTruthy();
|
||||||
expect(SomeDirective.hasOwnProperty('ngDirectiveDef')).toBeTruthy();
|
expect(SomeDirective.hasOwnProperty('ɵdir')).toBeTruthy();
|
||||||
|
|
||||||
expect(PipeWithNoAnnotations.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
expect(PipeWithNoAnnotations.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
||||||
expect(SomePipe.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
expect(SomePipe.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
||||||
@ -667,12 +667,12 @@ describe('TestBed', () => {
|
|||||||
|
|
||||||
// ng defs should be removed from classes with no annotations
|
// ng defs should be removed from classes with no annotations
|
||||||
expect(ComponentWithNoAnnotations.hasOwnProperty('ɵcmp')).toBeFalsy();
|
expect(ComponentWithNoAnnotations.hasOwnProperty('ɵcmp')).toBeFalsy();
|
||||||
expect(DirectiveWithNoAnnotations.hasOwnProperty('ngDirectiveDef')).toBeFalsy();
|
expect(DirectiveWithNoAnnotations.hasOwnProperty('ɵdir')).toBeFalsy();
|
||||||
expect(PipeWithNoAnnotations.hasOwnProperty('ngPipeDef')).toBeFalsy();
|
expect(PipeWithNoAnnotations.hasOwnProperty('ngPipeDef')).toBeFalsy();
|
||||||
|
|
||||||
// ng defs should be preserved on super types
|
// ng defs should be preserved on super types
|
||||||
expect(SomeComponent.hasOwnProperty('ɵcmp')).toBeTruthy();
|
expect(SomeComponent.hasOwnProperty('ɵcmp')).toBeTruthy();
|
||||||
expect(SomeDirective.hasOwnProperty('ngDirectiveDef')).toBeTruthy();
|
expect(SomeDirective.hasOwnProperty('ɵdir')).toBeTruthy();
|
||||||
expect(SomePipe.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
expect(SomePipe.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ResourceLoader} from '@angular/compiler';
|
import {ResourceLoader} from '@angular/compiler';
|
||||||
import {ApplicationInitStatus, COMPILER_OPTIONS, Compiler, Component, Directive, Injector, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, Type, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIRECTIVE_DEF as NG_DIRECTIVE_DEF, ɵNG_INJECTOR_DEF as NG_INJECTOR_DEF, ɵNG_MODULE_DEF as NG_MODULE_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDef as InjectableDef} from '@angular/core';
|
import {ApplicationInitStatus, COMPILER_OPTIONS, Compiler, Component, Directive, Injector, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, Type, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJECTOR_DEF as NG_INJECTOR_DEF, ɵNG_MODULE_DEF as NG_MODULE_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDef as InjectableDef} from '@angular/core';
|
||||||
import {ModuleRegistrationMap, getRegisteredModulesState, restoreRegisteredModulesState} from '../../src/linker/ng_module_factory_registration';
|
import {ModuleRegistrationMap, getRegisteredModulesState, restoreRegisteredModulesState} from '../../src/linker/ng_module_factory_registration';
|
||||||
|
|
||||||
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
|
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
|
||||||
@ -305,7 +305,7 @@ export class R3TestBedCompiler {
|
|||||||
|
|
||||||
this.pendingDirectives.forEach(declaration => {
|
this.pendingDirectives.forEach(declaration => {
|
||||||
const metadata = this.resolvers.directive.resolve(declaration);
|
const metadata = this.resolvers.directive.resolve(declaration);
|
||||||
this.maybeStoreNgDef(NG_DIRECTIVE_DEF, declaration);
|
this.maybeStoreNgDef(NG_DIR_DEF, declaration);
|
||||||
compileDirective(declaration, metadata);
|
compileDirective(declaration, metadata);
|
||||||
});
|
});
|
||||||
this.pendingDirectives.clear();
|
this.pendingDirectives.clear();
|
||||||
@ -350,7 +350,7 @@ export class R3TestBedCompiler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.seenComponents.forEach(maybeApplyOverrides(NG_COMP_DEF));
|
this.seenComponents.forEach(maybeApplyOverrides(NG_COMP_DEF));
|
||||||
this.seenDirectives.forEach(maybeApplyOverrides(NG_DIRECTIVE_DEF));
|
this.seenDirectives.forEach(maybeApplyOverrides(NG_DIR_DEF));
|
||||||
|
|
||||||
this.seenComponents.clear();
|
this.seenComponents.clear();
|
||||||
this.seenDirectives.clear();
|
this.seenDirectives.clear();
|
||||||
@ -450,7 +450,7 @@ export class R3TestBedCompiler {
|
|||||||
|
|
||||||
const directive = this.resolvers.directive.resolve(type);
|
const directive = this.resolvers.directive.resolve(type);
|
||||||
if (directive) {
|
if (directive) {
|
||||||
if (!type.hasOwnProperty(NG_DIRECTIVE_DEF)) {
|
if (!type.hasOwnProperty(NG_DIR_DEF)) {
|
||||||
this.pendingDirectives.add(type);
|
this.pendingDirectives.add(type);
|
||||||
}
|
}
|
||||||
this.seenDirectives.add(type);
|
this.seenDirectives.add(type);
|
||||||
|
4
tools/public_api_guard/common/common.d.ts
vendored
4
tools/public_api_guard/common/common.d.ts
vendored
@ -224,8 +224,8 @@ export declare class NgClassBase {
|
|||||||
getValue(): {
|
getValue(): {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} | null;
|
} | null;
|
||||||
static ngDirectiveDef: any;
|
|
||||||
static ngFactoryDef: any;
|
static ngFactoryDef: any;
|
||||||
|
static ɵdir: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class NgComponentOutlet implements OnChanges, OnDestroy {
|
export declare class NgComponentOutlet implements OnChanges, OnDestroy {
|
||||||
@ -309,8 +309,8 @@ export declare class NgStyleBase {
|
|||||||
getValue(): {
|
getValue(): {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} | null;
|
} | null;
|
||||||
static ngDirectiveDef: any;
|
|
||||||
static ngFactory: any;
|
static ngFactory: any;
|
||||||
|
static ɵdir: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare class NgSwitch {
|
export declare class NgSwitch {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user