Extend to run fixBrowserCompatibilityIssuesInCSS over inline stylesheets (#1279)

* Extend to run fixBrowserCompatibilityIssuesInCSS over styles in inline style sheets

* Apply formatting changes

---------

Co-authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
This commit is contained in:
Eoghan Murray
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 26084f9bf7
commit 6de70cbf21
3 changed files with 13 additions and 12 deletions

View File

@@ -51,16 +51,6 @@ function getValidTagName(element: HTMLElement): Lowercase<string> {
return processedTagName;
}
function stringifyStyleSheet(sheet: CSSStyleSheet): string {
return sheet.cssRules
? Array.from(sheet.cssRules)
.map((rule) =>
rule.cssText ? validateStringifiedCssRule(rule.cssText) : '',
)
.join('')
: '';
}
function extractOrigin(url: string): string {
let origin = '';
if (url.indexOf('//') > -1) {
@@ -564,7 +554,7 @@ function serializeTextNode(
// to _only_ include the current rule(s) added by the text node.
// So we'll be conservative and keep textContent as-is.
} else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {
textContent = stringifyStyleSheet(
textContent = getCssRulesString(
(n.parentNode as HTMLStyleElement).sheet!,
);
}