Skip to content

Commit

Permalink
fix(transform): 🐛 fix node14 replaceAll
Browse files Browse the repository at this point in the history
  • Loading branch information
MellowCo committed Jul 17, 2022
1 parent 07893c6 commit 85ec374
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/transform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ const rules: Record<string, string> = {
* @param selector
*/
export function restoreSelector(selector: string) {
for (const rule in rules)
selector = selector.replaceAll(rules[rule], rule)
for (const rule in rules) {
const replaceReg = new RegExp(rules[rule], 'g')
selector = selector.replace(replaceReg, rules[rule])
}
return selector
}

Expand All @@ -33,7 +35,6 @@ export function transformSelector(selector: string) {
if (/[\.\/:%!#\(\)\[\]$]/.test(selector)) {
for (const rule in rules) {
const replaceReg = new RegExp(escapeRegExp(`\\${rule}`), 'g')
// selector = selector.replace(replaceReg, transformRules[transformRule])
selector = selector.replace(replaceReg, rules[rule])
}
}
Expand Down

0 comments on commit 85ec374

Please sign in to comment.