From: Ash Date: Wed, 23 Jan 2019 00:45:21 +0000 (+0000) Subject: [bugfix] Fix #4962 updateLocale with null to reset (#4966) X-Git-Tag: 2.25.0~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a06e7a0db2c83fb92aa72bbf6bde955d4c75a16;p=thirdparty%2Fmoment.git [bugfix] Fix #4962 updateLocale with null to reset (#4966) --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index af28bfe27..b0e030dba 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -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]; } diff --git a/src/test/moment/locale_update.js b/src/test/moment/locale_update.js index 3a525e279..35f727bba 100644 --- a/src/test/moment/locale_update.js +++ b/src/test/moment/locale_update.js @@ -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); +});