File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ define([], function( ) {
2
2
3
3
return function ( args ) {
4
4
return JSON . stringify ( args , function ( key , value ) {
5
- if ( typeof value === "function" ) {
6
- return value . runtimeKey ; // if undefined, the value will be filtered out.
5
+ if ( value && value . runtimeKey ) {
6
+ return value . runtimeKey ;
7
7
}
8
8
return value ;
9
9
} ) ;
Original file line number Diff line number Diff line change @@ -29,10 +29,19 @@ Globalize._validateParameterPresence = validateParameterPresence;
29
29
Globalize . _validateParameterTypeNumber = validateParameterTypeNumber ;
30
30
Globalize . _validateParameterTypeString = validateParameterTypeString ;
31
31
32
+ // Stamp runtimeKey and return cached fn.
33
+ // Note, this function isn't made common to all formatters and parsers, because in practice this is
34
+ // only used (at the moment) for numberFormatter used by unitFormatter.
35
+ // TODO: Move this function into a common place when this is used by different formatters.
36
+ function cached ( runtimeKey ) {
37
+ Globalize [ runtimeKey ] . runtimeKey = runtimeKey ;
38
+ return Globalize [ runtimeKey ] ;
39
+ }
40
+
32
41
Globalize . numberFormatter =
33
42
Globalize . prototype . numberFormatter = function ( options ) {
34
43
options = options || { } ;
35
- return Globalize [ runtimeKey ( "numberFormatter" , this . _locale , [ options ] ) ] ;
44
+ return cached ( runtimeKey ( "numberFormatter" , this . _locale , [ options ] ) ) ;
36
45
} ;
37
46
38
47
Globalize . numberParser =
You can’t perform that action at this time.
0 commit comments