feat(ivy): properly handle inheriting lifecycle hooks from plain classes (#27965)

PR Close #27965
This commit is contained in:
Ben Lesh 2018-12-26 11:08:46 -08:00 committed by Andrew Kushnir
parent 091a8a6fd5
commit b0caf02d4f
1 changed files with 10 additions and 8 deletions

View File

@ -35,6 +35,8 @@ function getSuperType(type: Type<any>): Type<any>&
export function InheritDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
let superType = getSuperType(definition.type);
debugger;
while (superType) {
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
if (isComponentDef(definition)) {
@ -156,18 +158,18 @@ export function InheritDefinitionFeature(definition: DirectiveDef<any>| Componen
} else {
// Even if we don't have a definition, check the type for the hooks and use those if need be
const superPrototype = superType.prototype;
if (superPrototype) {
definition.afterContentChecked =
definition.afterContentChecked || superPrototype.afterContentChecked;
definition.afterContentChecked || superPrototype.ngAfterContentChecked;
definition.afterContentInit =
definition.afterContentInit || superPrototype.afterContentInit;
definition.afterContentInit || superPrototype.ngAfterContentInit;
definition.afterViewChecked =
definition.afterViewChecked || superPrototype.afterViewChecked;
definition.afterViewInit = definition.afterViewInit || superPrototype.afterViewInit;
definition.doCheck = definition.doCheck || superPrototype.doCheck;
definition.onDestroy = definition.onDestroy || superPrototype.onDestroy;
definition.onInit = definition.onInit || superPrototype.onInit;
definition.afterViewChecked || superPrototype.ngAfterViewChecked;
definition.afterViewInit = definition.afterViewInit || superPrototype.ngAfterViewInit;
definition.doCheck = definition.doCheck || superPrototype.ngDoCheck;
definition.onDestroy = definition.onDestroy || superPrototype.ngOnDestroy;
definition.onInit = definition.onInit || superPrototype.ngOnInit;
definition.onChanges = definition.onChanges || superPrototype.ngOnChanges;
}
}