diff --git a/packages/animations/browser/src/dsl/animation_transition_factory.ts b/packages/animations/browser/src/dsl/animation_transition_factory.ts index 1bef38bf07d01..7368d93dd3fb8 100644 --- a/packages/animations/browser/src/dsl/animation_transition_factory.ts +++ b/packages/animations/browser/src/dsl/animation_transition_factory.ts @@ -191,7 +191,7 @@ export class AnimationStateStyles { } const normalizedProp = this.normalizer.normalizePropertyName(prop, errors); val = this.normalizer.normalizeStyleValue(prop, normalizedProp, val, errors); - finalStyles.set(normalizedProp, val); + finalStyles.set(prop, val); }); } }); diff --git a/packages/core/test/animation/animations_with_web_animations_integration_spec.ts b/packages/core/test/animation/animations_with_web_animations_integration_spec.ts index 78909dd4ce8f1..d39dc7beb473f 100644 --- a/packages/core/test/animation/animations_with_web_animations_integration_spec.ts +++ b/packages/core/test/animation/animations_with_web_animations_integration_spec.ts @@ -567,6 +567,74 @@ describe('animation integration tests using web animations', function() { expect(elm.style.getPropertyValue('width')).toEqual('300px'); expect(elm.style.getPropertyValue('font-size')).toEqual('14px'); }); + + it('should apply correct state transitions for both CamelCase and kebab-case CSS properties', + () => { + @Component({ + selector: 'ani-cmp', + template: ` +
+
+ `, + animations: [ + trigger( + 'camelCaseTrigger', + [ + state('active', style({ + 'backgroundColor': 'green', + })), + transition( + 'inactive => active', + [ + style({ + 'backgroundColor': 'red', + }), + animate(500), + ]), + ]), + trigger( + 'kebab-case-trigger', + [ + state('active', style({ + 'background-color': 'green', + })), + transition( + 'inactive => active', + [ + style({ + 'background-color': 'red', + }), + animate(500), + ]), + ]), + ] + }) + class Cmp { + public status: 'active'|'inactive' = 'inactive'; + } + + TestBed.configureTestingModule({declarations: [Cmp]}); + + const engine = TestBed.inject(ɵAnimationEngine); + const fixture = TestBed.createComponent(Cmp); + const cmp = fixture.componentInstance; + fixture.detectChanges(); + + cmp.status = 'active'; + fixture.detectChanges(); + engine.flush(); + + expect(engine.players.length).toEqual(2); + const [camelCaseWebPlayer, kebabCaseWebPlayer] = engine.players.map( + player => (player as TransitionAnimationPlayer).getRealPlayer() as ɵWebAnimationsPlayer); + + [camelCaseWebPlayer, kebabCaseWebPlayer].forEach(webPlayer => { + expect(webPlayer.keyframes).toEqual([ + new Map([['backgroundColor', 'red'], ['offset', 0]]), + new Map([['backgroundColor', 'green'], ['offset', 1]]) + ]); + }); + }); }); })();