diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index 0d78335817..0856ad22a6 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -196,10 +196,11 @@ OpenLayers.String = { * otherwise. */ numericIf: function(value, trimWhitespace) { + var originalValue = value; if (trimWhitespace === true) { value = value.replace(/^\s*|\s*$/g, ""); } - return OpenLayers.String.isNumeric(value) ? parseFloat(value) : value; + return OpenLayers.String.isNumeric(value) ? parseFloat(value) : originalValue; } }; diff --git a/tests/BaseTypes.html b/tests/BaseTypes.html index a8af69be2b..3f1f87cfd2 100644 --- a/tests/BaseTypes.html +++ b/tests/BaseTypes.html @@ -221,9 +221,18 @@ {value: "1e", expect: "1e"}, {value: "1+e", expect: "1+e"}, {value: "1-e", expect: "1-e"}, - {value: " 27 ", expect: " 27 "} + {value: " 27 ", expect: " 27 ", expectWithTrim: 27}, + {value: " abc ", expect: " abc ", expectWithTrim: " abc "} ]; - t.plan(cases.length + 1); + var count = 0; + for (var i=0, ii=cases.length; i - 29.7 + 29.7 @@ -1005,7 +1005,7 @@ - 36.2 + 36.2