react-moment 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-moment",
3
3
  "description": "React component for the moment date library.",
4
- "version": "1.1.4",
4
+ "version": "1.2.0",
5
5
  "author": {
6
6
  "name": "Sean Hickey",
7
7
  "web": "https://headzoo.io"
package/src/index.jsx CHANGED
@@ -168,11 +168,7 @@ export default class Moment extends React.Component {
168
168
  parse = parse || Moment.globalParse;
169
169
  local = local || Moment.globalLocal;
170
170
  tz = tz || Moment.globalTimezone;
171
- if (Moment.globalLocale) {
172
- locale = Moment.globalLocale;
173
- } else {
174
- locale = locale || Moment.globalMoment.locale();
175
- }
171
+ locale = locale || Moment.globalLocale || Moment.globalMoment.locale();
176
172
 
177
173
  let datetime = null;
178
174
  if (utc) {
package/tests/index.jsx CHANGED
@@ -392,6 +392,22 @@ describe('react-moment', () => {
392
392
  expect(ReactDOM.findDOMNode(date).innerHTML).toEqual('19 avr. 1976');
393
393
  });
394
394
 
395
+ it('locale prop overrides globalLocale', () => {
396
+ // Set global locale to French
397
+ Moment.globalLocale = 'fr';
398
+
399
+ // Component with explicit English locale should override global French
400
+ const date = TestUtils.renderIntoDocument(
401
+ <Moment format="D MMM YYYY" locale="en" date="1976-04-19T12:59-0500" />
402
+ );
403
+
404
+ // Should display in English, not French
405
+ expect(ReactDOM.findDOMNode(date).innerHTML).toEqual('19 Apr 1976');
406
+
407
+ // Reset global locale
408
+ Moment.globalLocale = null;
409
+ });
410
+
395
411
  it('globalTimezone', () => {
396
412
  Moment.globalTimezone = 'America/Los_Angeles';
397
413
  const date = TestUtils.renderIntoDocument(