fix: Fix CSS rules captured in Safari (#1253)

* fix: Fix CSS rules captured in Safari

* Apply formatting changes

* add changeset

* fix

---------

Co-authored-by: mydea <mydea@users.noreply.github.com>
This commit is contained in:
Francesco Novy
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 5c3e1cf1e7
commit 3cf1b8b450
4 changed files with 34 additions and 1 deletions

View File

@@ -76,6 +76,17 @@ export function getCssRuleString(rule: CSSRule): string {
// ignore
}
}
return validateStringifiedCssRule(cssStringified);
}
export function validateStringifiedCssRule(cssStringified: string): string {
// Safari does not escape selectors with : properly
if (cssStringified.includes(':')) {
// Replace e.g. [aa:bb] with [aa\\:bb]
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
return cssStringified.replace(regex, '$1\\$2');
}
return cssStringified;
}