@@ -132,13 +132,17 @@ class NumberParserImpl {
132132  } 
133133
134134  parse ( value : string )  { 
135+     let  isGroupSymbolAllowed  =  this . formatter . resolvedOptions ( ) . useGrouping ; 
135136    // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD' 
136137    let  fullySanitizedValue  =  this . sanitize ( value ) ; 
137138
138-     if  ( this . symbols . group )  { 
139-       // Remove group characters, and replace decimal points and numerals with ASCII values. 
140-       fullySanitizedValue  =  replaceAll ( fullySanitizedValue ,  this . symbols . group ,  '' ) ; 
139+     // Return NaN if there is a group symbol but useGrouping is false 
140+     if  ( ! isGroupSymbolAllowed  &&  this . symbols . group  &&  fullySanitizedValue . includes ( this . symbols . group ) )  { 
141+       return  NaN ; 
142+     }  else  if  ( this . symbols . group )  { 
143+       fullySanitizedValue  =  fullySanitizedValue . replaceAll ( this . symbols . group ! ,  '' ) ; 
141144    } 
145+ 
142146    if  ( this . symbols . decimal )  { 
143147      fullySanitizedValue  =  fullySanitizedValue . replace ( this . symbols . decimal ! ,  '.' ) ; 
144148    } 
@@ -191,11 +195,11 @@ class NumberParserImpl {
191195    if  ( this . options . currencySign  ===  'accounting'  &&  CURRENCY_SIGN_REGEX . test ( value ) )  { 
192196      newValue  =  - 1  *  newValue ; 
193197    } 
194- 
195198    return  newValue ; 
196199  } 
197200
198201  sanitize ( value : string )  { 
202+     let  isGroupSymbolAllowed  =  this . formatter . resolvedOptions ( ) . useGrouping ; 
199203    // If the value is only a unit and it matches one of the formatted numbers where the value is part of the unit and doesn't have any numerals, then 
200204    // return the known value for that case. 
201205    if  ( this . symbols . noNumeralUnits . length  >  0  &&  this . symbols . noNumeralUnits . find ( obj  =>  obj . unit  ===  value ) )  { 
@@ -220,7 +224,6 @@ class NumberParserImpl {
220224      value  =  value . replace ( this . symbols . literals ,  '' ) ; 
221225    } 
222226
223- 
224227    // Replace the ASCII minus sign with the minus sign used in the current locale 
225228    // so that both are allowed in case the user's keyboard doesn't have the locale's minus sign. 
226229    if  ( this . symbols . minusSign )  { 
@@ -234,27 +237,27 @@ class NumberParserImpl {
234237        value  =  replaceAll ( value ,  ',' ,  this . symbols . decimal ) ; 
235238        value  =  replaceAll ( value ,  String . fromCharCode ( 1548 ) ,  this . symbols . decimal ) ; 
236239      } 
237-       if  ( this . symbols . group )  { 
240+       if  ( this . symbols . group   &&   isGroupSymbolAllowed )  { 
238241        value  =  replaceAll ( value ,  '.' ,  this . symbols . group ) ; 
239242      } 
240243    } 
241244
242245    // In some locale styles, such as swiss currency, the group character can be a special single quote 
243246    // that keyboards don't typically have. This expands the character to include the easier to type single quote. 
244-     if  ( this . symbols . group  ===  '’'  &&  value . includes ( "'" ) )  { 
247+     if  ( this . symbols . group  ===  '’'  &&  value . includes ( "'" )   &&   isGroupSymbolAllowed )  { 
245248      value  =  replaceAll ( value ,  "'" ,  this . symbols . group ) ; 
246249    } 
247250
248251    // fr-FR group character is narrow non-breaking space, char code 8239 (U+202F), but that's not a key on the french keyboard, 
249252    // so allow space and non-breaking space as a group char as well 
250-     if  ( this . options . locale  ===  'fr-FR'  &&  this . symbols . group )  { 
253+     if  ( this . options . locale  ===  'fr-FR'  &&  this . symbols . group   &&   isGroupSymbolAllowed )  { 
251254      value  =  replaceAll ( value ,  ' ' ,  this . symbols . group ) ; 
252255      value  =  replaceAll ( value ,  / \u00A0 / g,  this . symbols . group ) ; 
253256    } 
254257
255258    // If there are multiple decimal separators and only one group separator, swap them 
256259    if  ( this . symbols . decimal 
257-       &&  this . symbols . group 
260+       &&  ( this . symbols . group   &&   isGroupSymbolAllowed ) 
258261      &&  [ ...value . matchAll ( new  RegExp ( escapeRegex ( this . symbols . decimal ) ,  'g' ) ) ] . length  >  1 
259262      &&  [ ...value . matchAll ( new  RegExp ( escapeRegex ( this . symbols . group ) ,  'g' ) ) ] . length  <=  1 )  { 
260263      value  =  swapCharacters ( value ,  this . symbols . decimal ,  this . symbols . group ) ; 
@@ -263,7 +266,7 @@ class NumberParserImpl {
263266    // If the decimal separator is before the group separator, swap them 
264267    let  decimalIndex  =  value . indexOf ( this . symbols . decimal ! ) ; 
265268    let  groupIndex  =  value . indexOf ( this . symbols . group ! ) ; 
266-     if  ( this . symbols . decimal  &&  this . symbols . group  &&  decimalIndex  >  - 1  &&  groupIndex  >  - 1  &&  decimalIndex  <  groupIndex )  { 
269+     if  ( this . symbols . decimal  &&  ( this . symbols . group   &&   isGroupSymbolAllowed )  &&  decimalIndex  >  - 1  &&  groupIndex  >  - 1  &&  decimalIndex  <  groupIndex )  { 
267270      value  =  swapCharacters ( value ,  this . symbols . decimal ,  this . symbols . group ) ; 
268271    } 
269272
@@ -286,13 +289,13 @@ class NumberParserImpl {
286289    let  areOnlyGroupAndDecimalSymbols  =  [ ...nonDigits ] . every ( char  =>  allPossibleGroupAndDecimalSymbols . has ( char ) ) ; 
287290    let  oneSymbolNotMatching  =  ( 
288291      nonDigits . size  ===  2 
289-       &&  this . symbols . group 
292+       &&  ( this . symbols . group   &&   isGroupSymbolAllowed ) 
290293      &&  this . symbols . decimal 
291294      &&  ( ! nonDigits . has ( this . symbols . group ! )  ||  ! nonDigits . has ( this . symbols . decimal ! ) ) 
292295    ) ; 
293296    let  bothSymbolsNotMatching  =  ( 
294297      nonDigits . size  ===  2 
295-       &&  this . symbols . group 
298+       &&  ( this . symbols . group   &&   isGroupSymbolAllowed ) 
296299      &&  this . symbols . decimal 
297300      &&  ! nonDigits . has ( this . symbols . group ! )  &&  ! nonDigits . has ( this . symbols . decimal ! ) 
298301    ) ; 
@@ -318,6 +321,7 @@ class NumberParserImpl {
318321  } 
319322
320323  isValidPartialNumber ( value : string ,  minValue : number  =  - Infinity ,  maxValue : number  =  Infinity ) : boolean  { 
324+     let  isGroupSymbolAllowed  =  this . formatter . resolvedOptions ( ) . useGrouping ; 
321325    value  =  this . sanitize ( value ) ; 
322326
323327    // Remove minus or plus sign, which must be at the start of the string. 
@@ -333,7 +337,7 @@ class NumberParserImpl {
333337    } 
334338
335339    // Remove numerals, groups, and decimals 
336-     if  ( this . symbols . group )  { 
340+     if  ( this . symbols . group   &&   isGroupSymbolAllowed )  { 
337341      value  =  replaceAll ( value ,  this . symbols . group ,  '' ) ; 
338342    } 
339343    value  =  value . replace ( this . symbols . numeral ,  '' ) ; 
@@ -366,7 +370,8 @@ function getSymbols(locale: string, formatter: Intl.NumberFormat, intlOptions: I
366370    maximumSignificantDigits : 21 , 
367371    roundingIncrement : 1 , 
368372    roundingPriority : 'auto' , 
369-     roundingMode : 'halfExpand' 
373+     roundingMode : 'halfExpand' , 
374+     useGrouping : true 
370375  } ) ; 
371376  // Note: some locale's don't add a group symbol until there is a ten thousands place 
372377  let  allParts  =  symbolFormatter . formatToParts ( - 10000.111 ) ; 
0 commit comments