1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00

Use modern stylesheet selector (#15962)

This commit is contained in:
David Walsh 2022-09-26 12:09:38 -05:00 committed by GitHub
parent e4798b2536
commit 24a3156a2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = () => {