Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should raise an error when mutate locale property not string', () => {
// $ExpectError: need string
IntlViewerContext.locale = 123;
});
setLocale(locale: Locale) {
IntlViewerContext.locale = locale;
this.setState({locale});
const html = document.getElementsByTagName('html')[0];
if (html != null) {
html.lang = LOCALES[locale].bcp47;
}
document.body.className = LOCALES[locale].rtl ? 'rtl' : 'ltr';
}
setLocale(locale: Locale) {
IntlViewerContext.locale = locale;
this.setState({locale});
const html = document.getElementsByTagName('html')[0];
if (html != null) {
html.lang = LOCALES[locale].bcp47;
}
document.body.className = LOCALES[locale].rtl ? 'rtl' : 'ltr';
}