fix(Animation): Problem decimals using commas as decimal separation

Tests where failing due to `.` character being used as decimal separator in some regional settings (like spanish for example)

Closes #6335

Closes #6338
This commit is contained in:
Alfonso Presa 2016-01-08 01:10:48 +01:00 committed by Misko Hevery
parent 97e94dd6e0
commit 5f3d02bc7c
2 changed files with 10 additions and 0 deletions

View File

@ -184,6 +184,7 @@ export class Animation {
let value = NumberWrapper.parseInt(this.stripLetters(duration), 10);
if (value > maxValue) maxValue = value;
} else if (duration.substring(duration.length - 1) == 's') {
duration = StringWrapper.replace(duration, ',', '.');
let ms = NumberWrapper.parseFloat(this.stripLetters(duration)) * 1000;
let value = Math.floor(ms);
if (value > maxValue) maxValue = value;

View File

@ -93,6 +93,15 @@ export function main() {
}
}));
it('should support parsing when commas are used as decimal separator due to regional settings',
inject([AnimationBuilder], (animate) => {
var animateCss = animate.css();
var element = el(`<div></div>`);
var runner = animateCss.start(element);
expect(runner.parseDurationString('0,5s')).toBe(500);
expect(runner.parseDurationString('0.5s')).toBe(500);
}));
it('should add classes', inject([AnimationBuilder], (animate) => {
var animateCss = animate.css().addClass('one').addClass('two');
var element = el('<div></div>');