fix(ivy): ngOnChanges should be inherited from super class (#28563)

PR Close #28563
This commit is contained in:
Marc Laval
2019-02-06 15:03:42 +01:00
committed by Miško Hevery
parent fe8301c462
commit 94b8aaeba8
6 changed files with 105 additions and 89 deletions

View File

@ -12,6 +12,7 @@ import {fillProperties} from '../../util/property';
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
import {ComponentDef, DirectiveDef, DirectiveDefFeature, RenderFlags} from '../interfaces/definition';
import {NgOnChangesFeature} from './ng_onchanges_feature';
/**
@ -168,6 +169,10 @@ export function InheritDefinitionFeature(definition: DirectiveDef<any>| Componen
definition.doCheck = definition.doCheck || superPrototype.ngDoCheck;
definition.onDestroy = definition.onDestroy || superPrototype.ngOnDestroy;
definition.onInit = definition.onInit || superPrototype.ngOnInit;
if (superPrototype.ngOnChanges) {
NgOnChangesFeature()(definition);
}
}
}

View File

@ -151,9 +151,7 @@ function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMet
inputs: metadata.inputs || EMPTY_ARRAY,
outputs: metadata.outputs || EMPTY_ARRAY,
queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
lifecycle: {
usesOnChanges: type.prototype.ngOnChanges !== undefined,
},
lifecycle: {usesOnChanges: type.prototype.hasOwnProperty('ngOnChanges')},
typeSourceSpan: null !,
usesInheritance: !extendsDirectlyFromObject(type),
exportAs: extractExportAs(metadata.exportAs),