Skip to content

Commit

Permalink
Fix moment#3883 fallback to globalLocale if parentLocale can't be loa…
Browse files Browse the repository at this point in the history
…ded,

added test
  • Loading branch information
cmyers committed Nov 18, 2017
1 parent bb6dd57 commit c377b8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/locale/locales.js
Expand Up @@ -42,7 +42,7 @@ function chooseLocale(names) {
}
i++;
}
return null;
return globalLocale;
}

function loadLocale(name) {
Expand Down
3 changes: 3 additions & 0 deletions src/test/moment/locale_inheritance.js
Expand Up @@ -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('_')
});
Expand Down

0 comments on commit c377b8e

Please sign in to comment.