
committed by
Andrew Kushnir

parent
83c9bff242
commit
2f36a9591d
@ -146,7 +146,7 @@ export function InheritDefinitionFeature(definition: DirectiveDef<any>| Componen
|
||||
const features = superDef.features;
|
||||
if (features) {
|
||||
for (const feature of features) {
|
||||
if (feature && feature !== InheritDefinitionFeature) {
|
||||
if (feature && feature.ngInherit) {
|
||||
(feature as DirectiveDefFeature)(definition);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {SimpleChange} from '../../change_detection/change_detection_util';
|
||||
import {OnChanges, SimpleChanges} from '../../metadata/lifecycle_hooks';
|
||||
import {DirectiveDef} from '../interfaces/definition';
|
||||
import {DirectiveDef, DirectiveDefFeature} from '../interfaces/definition';
|
||||
|
||||
const PRIVATE_PREFIX = '__ngOnChanges_';
|
||||
|
||||
@ -106,6 +106,10 @@ export function NgOnChangesFeature<T>(definition: DirectiveDef<T>): void {
|
||||
definition.doCheck = onChangesWrapper(definition.doCheck);
|
||||
}
|
||||
|
||||
// This option ensures that the ngOnChanges lifecycle hook will be inherited
|
||||
// from superclasses (in InheritDefinitionFeature).
|
||||
(NgOnChangesFeature as DirectiveDefFeature).ngInherit = true;
|
||||
|
||||
function onChangesWrapper(delegateHook: (() => void) | null) {
|
||||
return function(this: OnChangesExpando) {
|
||||
const simpleChanges = this[PRIVATE_PREFIX];
|
||||
|
@ -307,8 +307,16 @@ export interface PipeDef<T> {
|
||||
|
||||
export type PipeDefWithMeta<T, Name extends string> = PipeDef<T>;
|
||||
|
||||
export type DirectiveDefFeature = <T>(directiveDef: DirectiveDef<T>) => void;
|
||||
export type ComponentDefFeature = <T>(componentDef: ComponentDef<T>) => void;
|
||||
export interface DirectiveDefFeature {
|
||||
<T>(directiveDef: DirectiveDef<T>): void;
|
||||
ngInherit?: true;
|
||||
}
|
||||
|
||||
export interface ComponentDefFeature {
|
||||
<T>(componentDef: ComponentDef<T>): void;
|
||||
ngInherit?: true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Type used for directiveDefs on component definition.
|
||||
|
Reference in New Issue
Block a user