mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 07:57:02 +03:00
Bugfix: typeCast() number could return NaN
This commit is contained in:
parent
2a14566679
commit
27d119c068
1 changed files with 7 additions and 3 deletions
|
|
@ -5,9 +5,13 @@ function typeCast(curValue, newValue) {
|
||||||
if (null != curValue) {
|
if (null != curValue) {
|
||||||
switch (typeof curValue)
|
switch (typeof curValue)
|
||||||
{
|
{
|
||||||
case 'boolean': return 0 != newValue && !!newValue;
|
case 'boolean':
|
||||||
case 'number': return isFinite(newValue) ? parseFloat(newValue) : 0;
|
return 0 != newValue && !!newValue;
|
||||||
case 'string': return null != newValue ? '' + newValue : '';
|
case 'number':
|
||||||
|
newValue = parseFloat(newValue);
|
||||||
|
return isFinite(newValue) ? newValue : 0;
|
||||||
|
case 'string':
|
||||||
|
return null != newValue ? '' + newValue : '';
|
||||||
case 'object':
|
case 'object':
|
||||||
if (curValue.constructor.reviveFromJson) {
|
if (curValue.constructor.reviveFromJson) {
|
||||||
return curValue.constructor.reviveFromJson(newValue);
|
return curValue.constructor.reviveFromJson(newValue);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue