Permalink
Browse files

make sure to only deserialize pure-numbers as numbers

  • Loading branch information...
sjmiles committed May 3, 2013
1 parent 0709e34 commit 6f04747ecd2f281dfc08273c2f1422cf24d138a8
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/attrs.js
View
@@ -93,6 +93,8 @@
return properties[properties.map(lowerCase).indexOf(name)];
};
+ var isNotNumber = /[^\d\.]/;
+
function deserializeValue(inValue, inDefaultValue) {
var inferredType = typeof inDefaultValue;
switch (inValue) {
@@ -101,9 +103,12 @@
return inferredType == 'boolean' ? true : inValue;
case 'false':
return inferredType == 'boolean' ? false : inValue;
- }
- var float = parseFloat(inValue);
- return isNaN(float) ? inValue : float;
+ }
+ if (isNotNumber.test(inValue)) {
+ return inValue;
+ }
+ var float = parseFloat(inValue);
+ return isNaN(float) ? inValue : float;
}
// exports

0 comments on commit 6f04747

Please sign in to comment.