Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
support extra number formats (i.e. hex) when deserializing numbers fr…
Browse files Browse the repository at this point in the history
…om markup
  • Loading branch information
Scott J. Miles committed Dec 14, 2013
1 parent c94c872 commit 34d9341
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
return value === 'false' ? false : !!value;
},
number: function(value) {
var floatVal = parseFloat(value);
return (String(floatVal) === value) ? floatVal : value;
var n = parseFloat(value);
// hex values like "0xFFFF" parseFloat as 0
if (n === 0) {
n = parseInt(value);
}
return isNaN(n) ? value : n;
// this code disabled because encoded values (like "0xFFFF")
// do not round trip to their original format
//return (String(floatVal) === value) ? floatVal : value;
},
object: function(value, currentValue) {
if (currentValue === null) {
Expand Down

0 comments on commit 34d9341

Please sign in to comment.