Skip to content

Commit 6c1064c

Browse files
dario-piotrowiczthePunderWoman
authored andcommitted
fix(animations): fix incorrect handling of camel-case css properties (#48436)
fix the issue of camel-case properties not being handled correctly in state transition causing them not to be applied to the element resolves #48246 PR Close #48436
1 parent 8981db4 commit 6c1064c

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

packages/animations/browser/src/dsl/animation_transition_factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class AnimationStateStyles {
191191
}
192192
const normalizedProp = this.normalizer.normalizePropertyName(prop, errors);
193193
val = this.normalizer.normalizeStyleValue(prop, normalizedProp, val, errors);
194-
finalStyles.set(normalizedProp, val);
194+
finalStyles.set(prop, val);
195195
});
196196
}
197197
});

packages/core/test/animation/animations_with_web_animations_integration_spec.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,74 @@ describe('animation integration tests using web animations', function() {
567567
expect(elm.style.getPropertyValue('width')).toEqual('300px');
568568
expect(elm.style.getPropertyValue('font-size')).toEqual('14px');
569569
});
570+
571+
it('should apply correct state transitions for both CamelCase and kebab-case CSS properties',
572+
() => {
573+
@Component({
574+
selector: 'ani-cmp',
575+
template: `
576+
<div id="camelCaseDiv" [@camelCaseTrigger]="status"></div>
577+
<div id="kebab-case-div" [@kebab-case-trigger]="status"></div>
578+
`,
579+
animations: [
580+
trigger(
581+
'camelCaseTrigger',
582+
[
583+
state('active', style({
584+
'backgroundColor': 'green',
585+
})),
586+
transition(
587+
'inactive => active',
588+
[
589+
style({
590+
'backgroundColor': 'red',
591+
}),
592+
animate(500),
593+
]),
594+
]),
595+
trigger(
596+
'kebab-case-trigger',
597+
[
598+
state('active', style({
599+
'background-color': 'green',
600+
})),
601+
transition(
602+
'inactive => active',
603+
[
604+
style({
605+
'background-color': 'red',
606+
}),
607+
animate(500),
608+
]),
609+
]),
610+
]
611+
})
612+
class Cmp {
613+
public status: 'active'|'inactive' = 'inactive';
614+
}
615+
616+
TestBed.configureTestingModule({declarations: [Cmp]});
617+
618+
const engine = TestBed.inject(ɵAnimationEngine);
619+
const fixture = TestBed.createComponent(Cmp);
620+
const cmp = fixture.componentInstance;
621+
fixture.detectChanges();
622+
623+
cmp.status = 'active';
624+
fixture.detectChanges();
625+
engine.flush();
626+
627+
expect(engine.players.length).toEqual(2);
628+
const [camelCaseWebPlayer, kebabCaseWebPlayer] = engine.players.map(
629+
player => (player as TransitionAnimationPlayer).getRealPlayer() as ɵWebAnimationsPlayer);
630+
631+
[camelCaseWebPlayer, kebabCaseWebPlayer].forEach(webPlayer => {
632+
expect(webPlayer.keyframes).toEqual([
633+
new Map<string, string|number>([['backgroundColor', 'red'], ['offset', 0]]),
634+
new Map<string, string|number>([['backgroundColor', 'green'], ['offset', 1]])
635+
]);
636+
});
637+
});
570638
});
571639
})();
572640

0 commit comments

Comments
 (0)