From 24a3156a2ba9e7ad55c44e3b5aa655d99bfbb500 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Mon, 26 Sep 2022 12:09:38 -0500 Subject: [PATCH] Use modern stylesheet selector (#15962) --- shared/lib/switch-direction.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 = () => {