Skip to content

Commit df1b90d

Browse files
committed
Make messageFormatterFn backwards compatible
The new version adds a string "call" parameter after the formatter function. Old bundles will not have this parameter, so messageFormatterFn will use the old behavior.
1 parent 7400ed1 commit df1b90d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/message.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ Globalize.prototype.messageFormatter = function( path ) {
115115
);
116116

117117
returnFn = messageFormatterFn.apply( this, [
118-
formatter,
118+
formatter, "call",
119119
runtime.number, runtime.plural, runtime.select, pluralGenerator
120120
].concat( compiler.formatters ) );
121121

122122
var runtimeArgs = [
123123
messageFormatterRuntimeBind(
124124
formatter, formatterSrc, compiler.runtime, pluralType, cldr.locale, compiler.formatters
125-
)
125+
),
126+
"call"
126127
];
127128

128129
if ( pluralGenerator ) {

src/message/formatter-fn.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ define([
22
"../common/validate/parameter-type/message-variables"
33
], function( validateParameterTypeMessageVariables ) {
44

5-
return function( formatter ) {
6-
formatter = formatter.apply( null, [].slice.call( arguments, 1 ) );
5+
return function( formatter, shouldCall ) {
6+
if ( shouldCall === "call" ) {
7+
formatter = formatter.apply( null, [].slice.call( arguments, 2 ) );
8+
}
79
return function messageFormatter( variables ) {
810
if ( typeof variables === "number" || typeof variables === "string" ) {
911
variables = [].slice.call( arguments, 0 );

0 commit comments

Comments
 (0)