@@ -80,14 +80,22 @@ function roundNumber(formatOptions) {
8080 formatOptions . decimalIndex = decimalIndex ;
8181}
8282
83+ function isConstantFormat ( format ) {
84+ return format . indexOf ( SHARP ) === - 1 && format . indexOf ( ZERO ) === - 1 ;
85+ }
86+
8387function setValueSpecificFormat ( formatOptions ) {
8488 let { number, format } = formatOptions ;
8589 format = format . split ( ";" ) ;
8690 if ( formatOptions . negative && format [ 1 ] ) {
8791 format = format [ 1 ] ;
8892 formatOptions . hasNegativeFormat = true ;
8993 } else if ( number === 0 ) {
90- format = format [ 2 ] || format [ 0 ] ;
94+ const zeroFormat = format [ 2 ] ;
95+ format = zeroFormat || format [ 0 ] ;
96+ if ( zeroFormat && isConstantFormat ( zeroFormat ) ) {
97+ formatOptions . constant = zeroFormat ;
98+ }
9199 } else {
92100 format = format [ 0 ] ;
93101 }
@@ -246,10 +254,6 @@ function applyCustomFormat(formatOptions, info) {
246254 return number ;
247255}
248256
249- function isConstantFormat ( format ) {
250- return format . indexOf ( SHARP ) === - 1 && format . indexOf ( ZERO ) === - 1 ;
251- }
252-
253257export default function customNumberFormat ( number , format , info ) {
254258 const formatOptions = {
255259 negative : number < 0 ,
@@ -259,8 +263,8 @@ export default function customNumberFormat(number, format, info) {
259263
260264 setValueSpecificFormat ( formatOptions ) ;
261265
262- if ( isConstantFormat ( formatOptions . format ) ) {
263- return formatOptions . format ;
266+ if ( formatOptions . constant ) {
267+ return formatOptions . constant ;
264268 }
265269
266270 setFormatLiterals ( formatOptions ) ;
0 commit comments