From 34d9341b2cafe81904fe803a8232ae79d1a2122e Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Wed, 11 Dec 2013 14:03:22 -0800 Subject: [PATCH] support extra number formats (i.e. hex) when deserializing numbers from markup --- src/lib/deserialize.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/deserialize.js b/src/lib/deserialize.js index c3e1134..02d43ee 100644 --- a/src/lib/deserialize.js +++ b/src/lib/deserialize.js @@ -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) {