fix(animations): support multiple state names per state() call (#15147)

Closes #14732
Closes #15147
This commit is contained in:
Matias Niemelä 2017-03-15 09:24:09 -07:00 committed by Chuck Jazdzewski
parent 5c0ea20bd0
commit 36ce0afff6
2 changed files with 11 additions and 1 deletions

View File

@ -86,7 +86,8 @@ class AnimationTriggerVisitor implements AnimationDslVisitor {
}
visitState(ast: AnimationStateMetadata, context: any): any {
context.states[ast.name] = normalizeStyles(ast.styles.styles);
const styles = normalizeStyles(ast.styles.styles);
ast.name.split(/\s*,\s*/).forEach(name => { context.states[name] = styles; });
}
visitTransition(ast: AnimationTransitionMetadata, context: any): any {

View File

@ -51,6 +51,15 @@ export function main() {
expect(result.transitionFactories.length).toEqual(2);
});
it('should allow multiple state values to use the same styles', () => {
const result = makeTrigger('name', [
state('on, off', style({width: 50})), transition('on => off', animate(1000)),
transition('off => on', animate(1000))
]);
expect(result.states).toEqual({'on': {width: 50}, 'off': {width: 50}});
});
it('should find the first transition that matches', () => {
const result = makeTrigger(
'name', [transition('a => b', animate(1234)), transition('b => c', animate(5678))]);