From 5f3d02bc7cf4149f9eb389cf003c7823aebcbf44 Mon Sep 17 00:00:00 2001 From: Alfonso Presa Date: Fri, 8 Jan 2016 01:10:48 +0100 Subject: [PATCH] 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 --- .../@angular/platform-browser/src/animate/animation.ts | 1 + .../test/animate/animation_builder_spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/modules/@angular/platform-browser/src/animate/animation.ts b/modules/@angular/platform-browser/src/animate/animation.ts index f5f5ec82a5..dc2ef2713f 100644 --- a/modules/@angular/platform-browser/src/animate/animation.ts +++ b/modules/@angular/platform-browser/src/animate/animation.ts @@ -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; diff --git a/modules/@angular/platform-browser/test/animate/animation_builder_spec.ts b/modules/@angular/platform-browser/test/animate/animation_builder_spec.ts index c48c0236ad..9bda4ef1f9 100644 --- a/modules/@angular/platform-browser/test/animate/animation_builder_spec.ts +++ b/modules/@angular/platform-browser/test/animate/animation_builder_spec.ts @@ -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(`
`); + 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('
');