]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[bugfix] Fix #4962 updateLocale with null to reset (#4966)
authorAsh <ash@hexmen.com>
Wed, 23 Jan 2019 00:45:21 +0000 (00:45 +0000)
committerKunal Marwaha <marwahaha@berkeley.edu>
Wed, 23 Jan 2019 00:45:21 +0000 (16:45 -0800)
src/lib/locale/locales.js
src/test/moment/locale_update.js

index af28bfe27f74ab1ed94d1cd6296e43b85a16f8a5..b0e030dba8eef38e9f631581698b558907051153 100644 (file)
@@ -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];
             }
index 3a525e2796dc203d9e233cc1a9800d096d176c44..35f727bba523ba19a81e62da4fb3cd17be45ee00 100644 (file)
@@ -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);
+});