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 56e7221611d77157a65130c7eda8a4ef69e00968..016418fb4cca44f9585bfeed676ebf0ee13329f6 100644 |
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
@@ -275,18 +275,22 @@ 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 not allow leading or trailing whitespace. |
+ // We do allow leading or trailing whitespace. |
if (!JS('bool', |
- r'/^\s*(?:NaN|[+-]?(?:Infinity|' |
- r'(?:\.\d+|\d+(?:\.\d+)?)(?:[eE][+-]?\d+)?))\s*$/.test(#)', |
+ r'/^\s*[+-]?(?:Infinity|NaN|' |
+ r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)', |
source)) { |
return handleError(source); |
} |
var result = JS('num', r'parseFloat(#)', source); |
- if (result.isNaN && source != 'NaN') { |
+ if (result.isNaN) { |
+ var trimmed = source.trim(); |
+ if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') { |
+ return result; |
+ } |
return handleError(source); |
} |
return result; |