feat(ivy): properly handle inheriting lifecycle hooks from plain classes (#27965)
PR Close #27965
This commit is contained in:
parent
091a8a6fd5
commit
b0caf02d4f
|
@ -35,6 +35,8 @@ function getSuperType(type: Type<any>): Type<any>&
|
||||||
export function InheritDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
|
export function InheritDefinitionFeature(definition: DirectiveDef<any>| ComponentDef<any>): void {
|
||||||
let superType = getSuperType(definition.type);
|
let superType = getSuperType(definition.type);
|
||||||
|
|
||||||
|
debugger;
|
||||||
|
|
||||||
while (superType) {
|
while (superType) {
|
||||||
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
|
let superDef: DirectiveDef<any>|ComponentDef<any>|undefined = undefined;
|
||||||
if (isComponentDef(definition)) {
|
if (isComponentDef(definition)) {
|
||||||
|
@ -156,18 +158,18 @@ export function InheritDefinitionFeature(definition: DirectiveDef<any>| Componen
|
||||||
} else {
|
} else {
|
||||||
// Even if we don't have a definition, check the type for the hooks and use those if need be
|
// Even if we don't have a definition, check the type for the hooks and use those if need be
|
||||||
const superPrototype = superType.prototype;
|
const superPrototype = superType.prototype;
|
||||||
|
|
||||||
if (superPrototype) {
|
if (superPrototype) {
|
||||||
definition.afterContentChecked =
|
definition.afterContentChecked =
|
||||||
definition.afterContentChecked || superPrototype.afterContentChecked;
|
definition.afterContentChecked || superPrototype.ngAfterContentChecked;
|
||||||
definition.afterContentInit =
|
definition.afterContentInit =
|
||||||
definition.afterContentInit || superPrototype.afterContentInit;
|
definition.afterContentInit || superPrototype.ngAfterContentInit;
|
||||||
definition.afterViewChecked =
|
definition.afterViewChecked =
|
||||||
definition.afterViewChecked || superPrototype.afterViewChecked;
|
definition.afterViewChecked || superPrototype.ngAfterViewChecked;
|
||||||
definition.afterViewInit = definition.afterViewInit || superPrototype.afterViewInit;
|
definition.afterViewInit = definition.afterViewInit || superPrototype.ngAfterViewInit;
|
||||||
definition.doCheck = definition.doCheck || superPrototype.doCheck;
|
definition.doCheck = definition.doCheck || superPrototype.ngDoCheck;
|
||||||
definition.onDestroy = definition.onDestroy || superPrototype.onDestroy;
|
definition.onDestroy = definition.onDestroy || superPrototype.ngOnDestroy;
|
||||||
definition.onInit = definition.onInit || superPrototype.onInit;
|
definition.onInit = definition.onInit || superPrototype.ngOnInit;
|
||||||
|
definition.onChanges = definition.onChanges || superPrototype.ngOnChanges;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue