Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(animations): fix incorrect handling of camel-case css properties #48436

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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);
});
}
});
Expand Down
Expand Up @@ -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: `
<div id="camelCaseDiv" [@camelCaseTrigger]="status"></div>
<div id="kebab-case-div" [@kebab-case-trigger]="status"></div>
`,
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<string, string|number>([['backgroundColor', 'red'], ['offset', 0]]),
new Map<string, string|number>([['backgroundColor', 'green'], ['offset', 1]])
]);
});
});
});
})();

Expand Down