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:

committed by
Miško Hevery

parent
d8249d1230
commit
1a67d70bf8
@ -583,7 +583,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// SomeDirective definition should be:
|
||||
const SomeDirectiveDefinition = `
|
||||
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
SomeDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: SomeDirective,
|
||||
selectors: [["", "some-directive", ""]]
|
||||
});
|
||||
@ -620,7 +620,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
|
||||
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, MyComponentDefinition, 'Incorrect MyComponentDefinition.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ngFactoryDef');
|
||||
@ -646,7 +646,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// SomeDirective definition should be:
|
||||
const SomeDirectiveDefinition = `
|
||||
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
SomeDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: SomeDirective,
|
||||
selectors: [["div", "some-directive", "", 8, "foo", 3, "title", "", 9, "baz"]]
|
||||
});
|
||||
@ -657,7 +657,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// OtherDirective definition should be:
|
||||
const OtherDirectiveDefinition = `
|
||||
OtherDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
OtherDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: OtherDirective,
|
||||
selectors: [["", 5, "span", "title", "", 9, "baz"]]
|
||||
});
|
||||
@ -669,9 +669,9 @@ describe('compiler compliance', () => {
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
|
||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ɵdir');
|
||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
||||
expectEmit(source, OtherDirectiveDefinition, 'Incorrect OtherDirective.ngDirectiveDef');
|
||||
expectEmit(source, OtherDirectiveDefinition, 'Incorrect OtherDirective.ɵdir');
|
||||
expectEmit(source, OtherDirectiveFactory, 'Incorrect OtherDirective.ngFactoryDef');
|
||||
});
|
||||
|
||||
@ -789,7 +789,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const IfDirectiveDefinition = `
|
||||
IfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
IfDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: IfDirective,
|
||||
selectors: [["", "if", ""]]
|
||||
});`;
|
||||
@ -835,7 +835,7 @@ describe('compiler compliance', () => {
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ngDirectiveDef');
|
||||
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ɵdir');
|
||||
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ngFactoryDef');
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
|
||||
@ -2595,7 +2595,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// TODO(benlesh): Enforce this when the directives are specified
|
||||
const ForDirectiveDefinition = `
|
||||
ForOfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
ForOfDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: ForOfDirective,
|
||||
selectors: [["", "forOf", ""]],
|
||||
features: [$r3$.ɵɵNgOnChangesFeature()],
|
||||
@ -2676,7 +2676,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// TODO(chuckj): Enforce this when the directives are specified
|
||||
const ForDirectiveDefinition = `
|
||||
ForOfDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
ForOfDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: ForOfDirective,
|
||||
selectors: [["", "forOf", ""]],
|
||||
features: [$r3$.ɵɵNgOnChangesFeature()],
|
||||
@ -2926,7 +2926,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// SomeDirective definition should be:
|
||||
const SomeDirectiveDefinition = `
|
||||
SomeDirective.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
SomeDirective.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: SomeDirective,
|
||||
selectors: [["", "some-directive", ""]],
|
||||
exportAs: ["someDir", "otherDir"]
|
||||
@ -2936,7 +2936,7 @@ describe('compiler compliance', () => {
|
||||
const result = compile(files, angularFiles);
|
||||
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', () => {
|
||||
|
@ -668,7 +668,7 @@ describe('compiler compliance: bindings', () => {
|
||||
};
|
||||
|
||||
const HostBindingDirDeclaration = `
|
||||
HostBindingDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
HostBindingDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: HostBindingDir,
|
||||
selectors: [["", "hostBindingDir", ""]],
|
||||
hostBindings: function HostBindingDir_HostBindings(rf, ctx, elIndex) {
|
||||
@ -761,7 +761,7 @@ describe('compiler compliance: bindings', () => {
|
||||
};
|
||||
|
||||
const HostAttributeDirDeclaration = `
|
||||
HostAttributeDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
HostAttributeDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: HostAttributeDir,
|
||||
selectors: [["", "hostAttributeDir", ""]],
|
||||
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
||||
@ -805,7 +805,7 @@ describe('compiler compliance: bindings', () => {
|
||||
const HostAttributeDirDeclaration = `
|
||||
const $c0$ = ["aria-label", "label"];
|
||||
…
|
||||
HostAttributeDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
HostAttributeDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
type: HostAttributeDir,
|
||||
selectors: [["", "hostAttributeDir", ""]],
|
||||
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,
|
||||
selectors: [["", "hostAttributeDir", ""]],
|
||||
hostBindings: function HostAttributeDir_HostBindings(rf, ctx, elIndex) {
|
||||
|
@ -66,7 +66,7 @@ describe('compiler compliance: listen()', () => {
|
||||
});`;
|
||||
|
||||
const directiveDef = `
|
||||
MyDirective.ngDirectiveDef = IDENT.ɵɵdefineDirective({
|
||||
MyDirective.ɵdir = IDENT.ɵɵdefineDirective({
|
||||
…
|
||||
inputs:{
|
||||
directiveInput: "directiveInput",
|
||||
|
@ -332,7 +332,7 @@ describe('compiler compliance: styling', () => {
|
||||
};
|
||||
|
||||
const template = `
|
||||
MyAnimDir.ngDirectiveDef = $r3$.ɵɵdefineDirective({
|
||||
MyAnimDir.ɵdir = $r3$.ɵɵdefineDirective({
|
||||
…
|
||||
hostBindings: function MyAnimDir_HostBindings(rf, ctx, elIndex) {
|
||||
if (rf & 1) {
|
||||
|
Reference in New Issue
Block a user