refactor: remove parseFloat from facades (#11446)

This commit is contained in:
Pawel Kozlowski 2016-09-08 22:54:10 +02:00 committed by Evan Martin
parent 7b24028437
commit 436af15d63
5 changed files with 8 additions and 12 deletions

View File

@ -8,7 +8,7 @@
import {CompileAnimationAnimateMetadata, CompileAnimationEntryMetadata, CompileAnimationGroupMetadata, CompileAnimationKeyframesSequenceMetadata, CompileAnimationMetadata, CompileAnimationSequenceMetadata, CompileAnimationStateDeclarationMetadata, CompileAnimationStateTransitionMetadata, CompileAnimationStyleMetadata, CompileAnimationWithStepsMetadata} from '../compile_metadata';
import {ListWrapper, StringMapWrapper} from '../facade/collection';
import {NumberWrapper, isArray, isBlank, isPresent, isString, isStringMap} from '../facade/lang';
import {isArray, isBlank, isPresent, isString, isStringMap} from '../facade/lang';
import {Math} from '../facade/math';
import {ParseError} from '../parse_util';
@ -504,7 +504,7 @@ function _parseTimeExpression(
return new _AnimationTimings(0, 0, null);
}
var durationMatch = NumberWrapper.parseFloat(matches[1]);
var durationMatch = parseFloat(matches[1]);
var durationUnit = matches[2];
if (durationUnit == 's') {
durationMatch *= _ONE_SECOND;
@ -514,7 +514,7 @@ function _parseTimeExpression(
var delayMatch = matches[3];
var delayUnit = matches[4];
if (isPresent(delayMatch)) {
var delayVal: number = NumberWrapper.parseFloat(delayMatch);
var delayVal: number = parseFloat(delayMatch);
if (isPresent(delayUnit) && delayUnit == 's') {
delayVal *= _ONE_SECOND;
}

View File

@ -276,8 +276,7 @@ class _Scanner {
this.advance();
}
var str: string = this.input.substring(start, this.index);
var value: number =
simple ? NumberWrapper.parseIntAutoRadix(str) : NumberWrapper.parseFloat(str);
var value: number = simple ? NumberWrapper.parseIntAutoRadix(str) : parseFloat(str);
return newNumberToken(start, value);
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {NumberWrapper, isArray, isPresent, isString} from '../facade/lang';
import {isArray, isPresent, isString} from '../facade/lang';
/**
* @experimental Animation support is experimental.
@ -339,7 +339,7 @@ export function style(
input.forEach(entry => {
var entryOffset = (entry as any /** TODO #9100 */)['offset'];
if (isPresent(entryOffset)) {
offset = offset == null ? NumberWrapper.parseFloat(entryOffset) : offset;
offset = offset == null ? parseFloat(entryOffset) : offset;
}
});
}

View File

@ -272,9 +272,6 @@ export class NumberWrapper {
throw new Error('Invalid integer literal when parsing ' + text + ' in base ' + radix);
}
// TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
static parseFloat(text: string): number { return parseFloat(text); }
static get NaN(): number { return NaN; }
static isNumeric(value: any): boolean { return !isNaN(value - parseFloat(value)); }

View File

@ -8,7 +8,7 @@
import {Directive, ElementRef, Renderer, forwardRef} from '@angular/core';
import {NumberWrapper, isBlank} from '../facade/lang';
import {isBlank} from '../facade/lang';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
@ -50,7 +50,7 @@ export class NumberValueAccessor implements ControlValueAccessor {
}
registerOnChange(fn: (_: number) => void): void {
this.onChange = (value) => { fn(value == '' ? null : NumberWrapper.parseFloat(value)); };
this.onChange = (value) => { fn(value == '' ? null : parseFloat(value)); };
}
registerOnTouched(fn: () => void): void { this.onTouched = fn; }