From e23a40759607432f666313d0df2867c275e4d2ae Mon Sep 17 00:00:00 2001 From: Bruno Date: Wed, 17 Apr 2024 16:53:56 +0100 Subject: [PATCH] fix: detectValue & parseDataValue not crashing with BigInt --- src/data/helper/dataValueHelper.ts | 2 +- src/data/helper/sourceHelper.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/helper/dataValueHelper.ts b/src/data/helper/dataValueHelper.ts index 89148d0f5b..18764920fa 100644 --- a/src/data/helper/dataValueHelper.ts +++ b/src/data/helper/dataValueHelper.ts @@ -67,7 +67,7 @@ export function parseDataValue( ? NaN // If string (like '-'), using '+' parse to NaN // If object, also parse to NaN - : +value; + : Number(value); }; diff --git a/src/data/helper/sourceHelper.ts b/src/data/helper/sourceHelper.ts index d1aa89d5ef..a4c47721a9 100644 --- a/src/data/helper/sourceHelper.ts +++ b/src/data/helper/sourceHelper.ts @@ -449,8 +449,8 @@ function doGuessOrdinal( function detectValue(val: OptionDataValue): BeOrdinalValue { const beStr = isString(val); // Consider usage convenience, '1', '2' will be treated as "number". - // `isFinit('')` get `true`. - if (val != null && isFinite(val as number) && val !== '') { + // `Number('')` (or any whitespace) is `0`. + if (val != null && Number.isFinite(Number(val)) && val !== '') { return beStr ? BE_ORDINAL.Might : BE_ORDINAL.Not; } else if (beStr && val !== '-') {