From 9fc5f7277d407b312981e6f37ef97a8aeca8b1ff Mon Sep 17 00:00:00 2001 From: mathuria Date: Fri, 26 May 2023 15:08:27 +0530 Subject: [PATCH] Adding check for config.locale.ietf to get default ltr --- libs/utils/utils.js | 2 +- test/utils/utils.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 522387658f..10e9df0513 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -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); diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 0befc4e1c7..f987773712 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -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'); }); });