Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
index 016418fb4cca44f9585bfeed676ebf0ee13329f6..56e7221611d77157a65130c7eda8a4ef69e00968 100644 |
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
@@ -275,22 +275,18 @@ class Primitives { |
if (handleError == null) handleError = _throwFormatException; |
// Notice that JS parseFloat accepts garbage at the end of the string. |
// Accept only: |
- // - [+/-]NaN |
+ // - NaN |
// - [+/-]Infinity |
// - a Dart double literal |
- // We do allow leading or trailing whitespace. |
+ // We do not allow leading or trailing whitespace. |
if (!JS('bool', |
- r'/^\s*[+-]?(?:Infinity|NaN|' |
- r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)', |
+ r'/^\s*(?:NaN|[+-]?(?:Infinity|' |
+ r'(?:\.\d+|\d+(?:\.\d+)?)(?:[eE][+-]?\d+)?))\s*$/.test(#)', |
source)) { |
return handleError(source); |
} |
var result = JS('num', r'parseFloat(#)', source); |
- if (result.isNaN) { |
- var trimmed = source.trim(); |
- if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') { |
- return result; |
- } |
+ if (result.isNaN && source != 'NaN') { |
return handleError(source); |
} |
return result; |