Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moment.locale() returns undefined after updating a non-existing locale #5043

Closed
keqingrong opened this issue Mar 18, 2019 · 0 comments · Fixed by #5470
Closed

moment.locale() returns undefined after updating a non-existing locale #5043

keqingrong opened this issue Mar 18, 2019 · 0 comments · Fixed by #5470

Comments

@keqingrong
Copy link

keqingrong commented Mar 18, 2019

Describe the bug
moment.locale() returns undefined after updating a non-existing locale.

To Reproduce

moment.locale('en');
console.log(moment.locale()); // 'en'
moment.updateLocale('dude', {});
console.log(moment.locale()); // undefined

Expected behavior
moment.updateLocale() should ignore the non-existing locale or fallback to moment.defineLocale(), and gives a warning just like what moment.defineLocale() did .

moment.locale('en');
console.log(moment.locale()); // 'en'
moment.updateLocale('dude', {});
// Deprecation warning: use moment.defineLocale(localeName, config) to create
// a new locale. moment.updateLocale(localeName, config) should only be used
// for changing an existing locale.
console.log(moment.locale()); // 'en' or 'dude'

Moment version
2.24.0

@keqingrong keqingrong changed the title return undefined moment.locale() returns undefined after updating a non-existing locale Mar 18, 2019
@keqingrong keqingrong reopened this Mar 18, 2019
nishantgupta204 added a commit to nishantgupta204/moment that referenced this issue May 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant