Skip to content

Commit

Permalink
fix(Animation): Problem decimals using commas as decimal separation
Browse files Browse the repository at this point in the history
Tests where failing due to `.` character being used as decimal separator in some regional settings (like spanish for example)

Closes #6335

Closes #6338
  • Loading branch information
alfonso-presa authored and mhevery committed May 25, 2016
1 parent 97e94dd commit 5f3d02b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/@angular/platform-browser/src/animate/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>');
Expand Down

0 comments on commit 5f3d02b

Please sign in to comment.