File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ function d3_locale_numberFormat(locale) {
7474 var zcomma = zfill && comma ;
7575
7676 return function ( value ) {
77+ // Local variable to prevent side effect
78+ var localSuffix = suffix ;
7779
7880 // Return the empty string for floats formatted as ints.
7981 if ( integer && ( value % 1 ) ) return "" ;
@@ -85,7 +87,7 @@ function d3_locale_numberFormat(locale) {
8587 if ( scale < 0 ) {
8688 var unit = d3 . formatPrefix ( value , precision ) ;
8789 value = unit . scale ( value ) ;
88- suffix = unit . symbol ;
90+ localSuffix = unit . symbol + localSuffix ;
8991 } else {
9092 value *= scale ;
9193 }
@@ -116,7 +118,7 @@ function d3_locale_numberFormat(locale) {
116118 return ( align === "<" ? negative + value + padding
117119 : align === ">" ? padding + negative + value
118120 : align === "^" ? padding . substring ( 0 , length >>= 1 ) + negative + value + padding . substring ( length )
119- : negative + ( zcomma ? value : padding + value ) ) + suffix ;
121+ : negative + ( zcomma ? value : padding + value ) ) + localSuffix ;
120122 } ;
121123 } ;
122124}
Original file line number Diff line number Diff line change @@ -21,7 +21,12 @@ suite.addBatch({
2121 "formats currencies" : function ( format ) {
2222 var f = format ( "$,.2f" ) ;
2323 assert . equal ( f ( 12345.67 ) , "12 345,67 руб." ) ;
24+ } ,
25+ "formats currencies" : function ( format ) {
26+ var f = format ( "$,.4s" ) ;
27+ assert . equal ( f ( 12345.67 ) , "12,35k руб." ) ;
2428 }
29+
2530 } ,
2631
2732 "timeFormat" : {
You can’t perform that action at this time.
0 commit comments