From fae6b04131c9fd4b9105a75194979ca09b0bc88a Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 8 Oct 2023 21:48:09 +0200 Subject: [PATCH] Remove replaceAsync() dependency on String.prototype.matchAll(). --- src/common/themes.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/themes.js b/src/common/themes.js index 408155d..d5e40dc 100644 --- a/src/common/themes.js +++ b/src/common/themes.js @@ -145,9 +145,13 @@ async getContentCSS() { contentCSS = contentCSS || (async () => { const replaceAsync = async (string, regexp, replacerFunction) => { - const replacements = await Promise.all( - Array.from(string.matchAll(regexp), - match => replacerFunction(...match))); + regexp.lastIndex = 0; + const promises = []; + for (let match; match = regexp.exec(string);) { + promises.push(replacerFunction(...match)); + } + const replacements = await Promise.all(promises); + regexp.lastIndex = 0; let i = 0; return string.replace(regexp, () => replacements[i++]); }