mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +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) {
|
||||
switch (typeof curValue)
|
||||
{
|
||||
case 'boolean': return 0 != newValue && !!newValue;
|
||||
case 'number': return isFinite(newValue) ? parseFloat(newValue) : 0;
|
||||
case 'string': return null != newValue ? '' + newValue : '';
|
||||
case 'boolean':
|
||||
return 0 != newValue && !!newValue;
|
||||
case 'number':
|
||||
newValue = parseFloat(newValue);
|
||||
return isFinite(newValue) ? newValue : 0;
|
||||
case 'string':
|
||||
return null != newValue ? '' + newValue : '';
|
||||
case 'object':
|
||||
if (curValue.constructor.reviveFromJson) {
|
||||
return curValue.constructor.reviveFromJson(newValue);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue