From c377b8ef67b7d5881263b38a2e16422fcb1fd680 Mon Sep 17 00:00:00 2001 From: Chris Myers Date: Sat, 18 Nov 2017 17:41:37 +0000 Subject: [PATCH] Fix #3883 fallback to globalLocale if parentLocale can't be loaded, added test --- src/lib/locale/locales.js | 2 +- src/test/moment/locale_inheritance.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index 6f595a01ff..484cb28994 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -42,7 +42,7 @@ function chooseLocale(names) { } i++; } - return null; + return globalLocale; } function loadLocale(name) { diff --git a/src/test/moment/locale_inheritance.js b/src/test/moment/locale_inheritance.js index b5e718db9f..177f04370a 100644 --- a/src/test/moment/locale_inheritance.js +++ b/src/test/moment/locale_inheritance.js @@ -173,6 +173,9 @@ test('define child locale before parent', function (assert) { months : 'First_Second_Third_Fourth_Fifth_Sixth_Seventh_Eighth_Ninth_Tenth_Eleventh_Twelveth '.split('_') }); assert.equal(moment.locale(), 'en', 'failed to set a locale requiring missing parent'); + + assert.equal(moment('00:00:00 01/January/2017', 'HH:mm:ss DD/MMM/YYYY', 'months-x').locale(), 'en', 'creating moment using child with undefined parent defaults to global'); + moment.defineLocale('base-months-x', { months : 'One_Two_Three_Four_Five_Six_Seven_Eight_Nine_Ten_Eleven_Twelve'.split('_') });