Skip to content

Commit fae6b04

Browse files
committed
Remove replaceAsync() dependency on String.prototype.matchAll().
1 parent 28972ba commit fae6b04

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/common/themes.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@
145145
async getContentCSS() {
146146
contentCSS = contentCSS || (async () => {
147147
const replaceAsync = async (string, regexp, replacerFunction) => {
148-
const replacements = await Promise.all(
149-
Array.from(string.matchAll(regexp),
150-
match => replacerFunction(...match)));
148+
regexp.lastIndex = 0;
149+
const promises = [];
150+
for (let match; match = regexp.exec(string);) {
151+
promises.push(replacerFunction(...match));
152+
}
153+
const replacements = await Promise.all(promises);
154+
regexp.lastIndex = 0;
151155
let i = 0;
152156
return string.replace(regexp, () => replacements[i++]);
153157
}

0 commit comments

Comments
 (0)