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

@@ -22,6 +22,7 @@ import {
getCssRulesString,
getInputType,
toLowerCase,
validateStringifiedCssRule,
} from './utils';
let _id = 1;
@@ -53,7 +54,9 @@ function getValidTagName(element: HTMLElement): Lowercase<string> {
function stringifyStyleSheet(sheet: CSSStyleSheet): string {
return sheet.cssRules
? Array.from(sheet.cssRules)
.map((rule) => rule.cssText || '')
.map((rule) =>
rule.cssText ? validateStringifiedCssRule(rule.cssText) : '',
)
.join('')
: '';
}