Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ describe('compiler compliance: styling', () => {
vars: 0,
template: function MyComponent_Template(rf, $ctx$) {
},
animations: [{name: 'foo123'}, {name: 'trigger123'}]
data: {
animations: [{name: 'foo123'}, {name: 'trigger123'}]
}
});
`;

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

Expand Down
3 changes: 2 additions & 1 deletion packages/compiler/src/render3/view/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions packages/core/src/render3/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,14 @@ 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 !;
const directiveTypes = componentDefinition.directives !;
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,
Expand Down
14 changes: 9 additions & 5 deletions packages/core/test/render3/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1605,10 +1605,12 @@ describe('render3 integration test', () => {
type: AnimComp,
consts: 0,
vars: 0,
animations: [
animA,
animB,
],
data: {
animations: [
animA,
animB,
],
},
selectors: [['foo']],
factory: () => new AnimComp(),
template: (rf: RenderFlags, ctx: AnimComp) => {}
Expand All @@ -1630,7 +1632,9 @@ describe('render3 integration test', () => {
type: AnimComp,
consts: 0,
vars: 0,
animations: [],
data: {
animations: [],
},
selectors: [['foo']],
factory: () => new AnimComp(),
template: (rf: RenderFlags, ctx: AnimComp) => {}
Expand Down