diff --git a/shared/lib/switch-direction.js b/shared/lib/switch-direction.js index efda544f2..5675a1725 100644 --- a/shared/lib/switch-direction.js +++ b/shared/lib/switch-direction.js @@ -9,17 +9,17 @@ const switchDirection = async (direction) => { // eslint-disable-next-line no-param-reassign direction = 'ltr'; } + let updatedLink; - Array.from(document.getElementsByTagName('link')) - .filter((link) => link.rel === 'stylesheet') - .forEach((link) => { - if (link.title === direction && link.disabled) { - link.disabled = false; - updatedLink = link; - } else if (link.title !== direction && !link.disabled) { - link.disabled = true; - } - }); + [...document.querySelectorAll('link[rel=stylesheet]')].forEach((link) => { + if (link.title === direction && link.disabled) { + link.disabled = false; + updatedLink = link; + } else if (link.title !== direction && !link.disabled) { + link.disabled = true; + } + }); + if (updatedLink) { return new Promise((resolve, reject) => { updatedLink.onload = () => {