Skip to content

Commit

Permalink
[bugfix] Fix #4962 updateLocale with null to reset (#4966)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashsearle authored and marwahaha committed Jan 23, 2019
1 parent e3d82a8 commit 6a06e7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/locale/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export function updateLocale(name, config) {
if (locales[name] != null) {
if (locales[name].parentLocale != null) {
locales[name] = locales[name].parentLocale;
if (name === getSetGlobalLocale()) {
getSetGlobalLocale(name);
}
} else if (locales[name] != null) {
delete locales[name];
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/moment/locale_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,13 @@ test('update existing locale', function (assert) {
assert.equal(moment('2017-02-01').format('YYYY MMM MMMM'), '2017 FEB Februar');
moment.updateLocale('de', null);
});

test('reset locale', function (assert) {
moment.locale('de');
var resultBeforeUpdate = moment('2017-02-01').format('YYYY MMM MMMM');
moment.updateLocale('de', {
monthsShort: ['JAN', 'FEB', 'MÄR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEZ']
});
moment.updateLocale('de', null);
assert.equal(moment('2017-02-01').format('YYYY MMM MMMM'), resultBeforeUpdate);
});

0 comments on commit 6a06e7a

Please sign in to comment.