fix(core): make subclass inherit developer-defined data (#35105)

PR Close #35105
This commit is contained in:
zhuyujie
2020-02-02 19:04:13 +08:00
committed by Alex Rickabaugh
parent 8e12707f88
commit a756161dc2
2 changed files with 170 additions and 3 deletions

View File

@ -7,11 +7,10 @@
*/
import {Type, Writable} from '../../interface/type';
import {assertEqual} from '../../util/assert';
import {fillProperties} from '../../util/property';
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
import {ComponentDef, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, HostBindingsFunction, RenderFlags, ViewQueriesFunction} from '../interfaces/definition';
import {AttributeMarker, TAttributes} from '../interfaces/node';
import {TAttributes} from '../interfaces/node';
import {isComponentDef} from '../interfaces/type_checks';
import {mergeHostAttrs} from '../util/attrs_utils';
@ -71,6 +70,15 @@ export function ɵɵInheritDefinitionFeature(definition: DirectiveDef<any>| Comp
fillProperties(definition.declaredInputs, superDef.declaredInputs);
fillProperties(definition.outputs, superDef.outputs);
// Merge animations metadata.
// If `superDef` is a Component, the `data` field is present (defaults to an empty object).
if (isComponentDef(superDef) && superDef.data.animation) {
// If super def is a Component, the `definition` is also a Component, since Directives can
// not inherit Components (we throw an error above and cannot reach this code).
const defData = (definition as ComponentDef<any>).data;
defData.animation = (defData.animation || []).concat(superDef.data.animation);
}
// Inherit hooks
// Assume super class inheritance feature has already run.
writeableDef.afterContentChecked =
@ -179,4 +187,4 @@ function inheritHostBindings(
} else {
definition.hostBindings = superHostBindings;
}
}
}