fix(ivy): remove unnecessary parameter of NgOnChangesFeature (#21879)

PR Close #21879
This commit is contained in:
Chuck Jazdzewski 2018-01-29 15:57:58 -08:00 committed by Alex Rickabaugh
parent 8b14488827
commit 65cf1add97
4 changed files with 50 additions and 52 deletions

View File

@ -67,10 +67,9 @@ type OnChangesExpando = OnChanges & {
[key: string]: any; [key: string]: any;
}; };
export function NgOnChangesFeature<T>(type: Type<T>): (definition: DirectiveDef<any>) => void { export function NgOnChangesFeature(definition: DirectiveDef<any>): void {
return function(definition: DirectiveDef<any>): void {
const inputs = definition.inputs; const inputs = definition.inputs;
const proto = type.prototype; const proto = definition.type.prototype;
// Place where we will store SimpleChanges if there is a change // Place where we will store SimpleChanges if there is a change
Object.defineProperty(proto, PRIVATE_PREFIX, {value: undefined, writable: true}); Object.defineProperty(proto, PRIVATE_PREFIX, {value: undefined, writable: true});
for (let pubKey in inputs) { for (let pubKey in inputs) {
@ -119,7 +118,6 @@ export function NgOnChangesFeature<T>(type: Type<T>): (definition: DirectiveDef<
delegateHook && delegateHook.apply(this); delegateHook && delegateHook.apply(this);
}; };
} }
};
} }

View File

@ -19,7 +19,7 @@ NgForOf.ngDirectiveDef = defineDirective({
factory: () => new NgForOfDef( factory: () => new NgForOfDef(
injectViewContainerRef(), injectTemplateRef(), injectViewContainerRef(), injectTemplateRef(),
inject(IterableDiffers, InjectFlags.Default, defaultIterableDiffers)), inject(IterableDiffers, InjectFlags.Default, defaultIterableDiffers)),
features: [NgOnChangesFeature(NgForOf)], features: [NgOnChangesFeature],
inputs: { inputs: {
ngForOf: 'ngForOf', ngForOf: 'ngForOf',
ngForTrackBy: 'ngForTrackBy', ngForTrackBy: 'ngForTrackBy',

View File

@ -426,7 +426,7 @@ describe('compiler specification', () => {
factory: () => new LifecycleComp(), factory: () => new LifecycleComp(),
template: function(ctx: any, cm: boolean) {}, template: function(ctx: any, cm: boolean) {},
inputs: {nameMin: 'name'}, inputs: {nameMin: 'name'},
features: [r3.NgOnChangesFeature(LifecycleComp)] features: [r3.NgOnChangesFeature]
}); });
} }

View File

@ -30,7 +30,7 @@ describe('define', () => {
static ngDirectiveDef = defineDirective({ static ngDirectiveDef = defineDirective({
type: MyDirective, type: MyDirective,
factory: () => new MyDirective(), factory: () => new MyDirective(),
features: [NgOnChangesFeature(MyDirective)], features: [NgOnChangesFeature],
inputs: {valA: 'valA', valB: 'valB'} inputs: {valA: 'valA', valB: 'valB'}
}); });
} }