refactor(ivy): handle animation metadata normalization in the compiler (#26481)

PR Close #26481
This commit is contained in:
Matias Niemelä 2018-10-16 11:09:04 -07:00 committed by Misko Hevery
parent 0f7d2ca7a8
commit 9e5d440a0b
4 changed files with 18 additions and 18 deletions

View File

@ -133,7 +133,9 @@ describe('compiler compliance: styling', () => {
vars: 0,
template: function MyComponent_Template(rf, $ctx$) {
},
data: {
animations: [{name: 'foo123'}, {name: 'trigger123'}]
}
});
`;
@ -173,7 +175,9 @@ describe('compiler compliance: styling', () => {
vars: 0,
template: function MyComponent_Template(rf, $ctx$) {
},
data: {
animations: []
}
});
`;

View File

@ -245,7 +245,8 @@ export function compileComponentFromMetadata(
// e.g. `animations: [trigger('123', [])]`
if (meta.animations !== null) {
definitionMap.set('animations', meta.animations);
definitionMap.set(
'data', o.literalMap([{key: 'animations', value: meta.animations, quoted: false}]));
}
// On the type side, remove newlines from the selector as it will need to fit into a TypeScript

View File

@ -263,11 +263,6 @@ export function defineComponent<T>(componentDefinition: {
* `PipeDefs`s. The function is necessary to be able to support forward declarations.
*/
pipes?: PipeTypesOrFactory | null;
/**
* Registry of the animation triggers present on the component that will be used by the view.
*/
animations?: any[] | null;
}): never {
const type = componentDefinition.type;
const pipeTypes = componentDefinition.pipes !;
@ -275,11 +270,7 @@ export function defineComponent<T>(componentDefinition: {
const declaredInputs: {[key: string]: string} = {} as any;
const encapsulation = componentDefinition.encapsulation || ViewEncapsulation.Emulated;
const styles: string[] = componentDefinition.styles || EMPTY_ARRAY;
const animations: any[]|null = componentDefinition.animations || null;
let data = componentDefinition.data || {};
if (animations) {
data.animations = animations;
}
const data = componentDefinition.data || {};
const def: ComponentDef<any> = {
type: type,
diPublic: null,

View File

@ -1605,10 +1605,12 @@ describe('render3 integration test', () => {
type: AnimComp,
consts: 0,
vars: 0,
data: {
animations: [
animA,
animB,
],
},
selectors: [['foo']],
factory: () => new AnimComp(),
template: (rf: RenderFlags, ctx: AnimComp) => {}
@ -1630,7 +1632,9 @@ describe('render3 integration test', () => {
type: AnimComp,
consts: 0,
vars: 0,
data: {
animations: [],
},
selectors: [['foo']],
factory: () => new AnimComp(),
template: (rf: RenderFlags, ctx: AnimComp) => {}