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 +1 -1
- package/src/index.jsx +1 -5
- package/tests/index.jsx +16 -0
package/package.json
CHANGED
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
|
-
|
|
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(
|