Skip to content

Commit

Permalink
Adding check for config.locale.ietf to get default ltr
Browse files Browse the repository at this point in the history
  • Loading branch information
aishwaryamathuria committed May 26, 2023
1 parent 6edbc06 commit 9fc5f72
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const [setConfig, getConfig] = (() => {
document.documentElement.setAttribute('lang', config.locale.ietf);
try {
const contentDir = getMetadata('content-direction');
document.documentElement.setAttribute('dir', contentDir || config.locale.dir || new Intl.Locale(config.locale.ietf)?.textInfo?.direction || 'ltr');
document.documentElement.setAttribute('dir', contentDir || config.locale.dir || (config.locale.ietf ? (new Intl.Locale(config.locale.ietf)?.textInfo?.direction) : null) || 'ltr');
} catch (e) {
// eslint-disable-next-line no-console
console.log('Invalid or missing locale:', e);
Expand Down
2 changes: 1 addition & 1 deletion test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('Utils', () => {

it('Gracefully dies when locale ietf is missing and dir is not set.', () => {
setConfigWithPath('/ua/solutions');
expect(document.documentElement.getAttribute('dir')).null;
expect(document.documentElement.getAttribute('dir')).to.equal('ltr');
});
});

Expand Down

0 comments on commit 9fc5f72

Please sign in to comment.